sockets

C# An existing connection was forcibly closed by the remote host: socket programming

hi, I am working on socket programming this code which i am going to show is client side code public void ReadCallback(IAsyncResult ar) { int fileNameLen = 1; String content = String.Empty; StateObject state = (StateObject)ar.AsyncState; Socket handler = state.workSocket; int bytesRead = ...

TCP keepalive sent almost right after connection.

I'm trying to implement an persistent TCP connection between an Android phone and a desktop server. I've got heartbeat threads on both ends which are sending keepalive-packets on application level successfully. The problem is that after a while (varies between 5-20min) the phone is starting to send TCP keepalives to the server, which t...

Socket connection from Java to Objective-C

I'm implementing a server push via a socket connection to an Objective-C based application. I'm at the point where I'm sending my data through an outputstream on the socket but I need to reassemble the data on the Objective-c end. At this point I haven't even looked at the objective-c IO classes and I am wondering how can I ensure maximu...

Java - Sending certificate through socket

Hi, i need to send a v3certificate from the server to the client using socket. To do this: server side, i generate a certificate which i encode with base64.encode , then i send it to the client. Client side, i receive the string which contain the certificate, Server code: X509Certificate certificate = ...; sendAnswer(new String(certi...

Problems writing a protocol on top of sockets in Java

Hi, I'm writing a protocol on top of sockets, so I've decided to implement headers then send the information. So there is one thread per connection on the server which sits there reading in headers, then delegates off to methods to read in the rest of the information when it arrives. So essentially it looks like this: while ((length ...

Approach for Client-Server Communication in Objective-C / Cocoa

Hey guys, I am working on an application for OS X that needs communication of small bits of data between a server side application and a client side application. I tried using a Ruby on Rails server as a backend way of communicating data, which was very simple and easy to implement but caused a bit of issues (I am not a proficient Ruby ...

SL4 AsyncEventArgs throws an InvalidOperationException after a second Socket connection

I have a class which has to send and receive data using sockets in Silverlight 4. It has to implement a pre-existing interface, so some things might look somewhat weird, but here it is: public class TcpDataTransportClient : IDataTransportService { private const string TCP_ADDRESS_SETTING = "tcpaddress"; private const string TCP_...

vb6, ZPL, socket printing

Hi there, I have done this programming in java and it works but can't make it run in vb6 (and I need to) Basically I need to send data to zebra printer over the network. The whole process works (no error reported but the printer does not print. In Java I have used: public void printOnions(ArrayList<String> DataArr){ // LH is x...

Is there a way to detect that TCP connection has been refused using flash.net.Socket?

There is a flash movie which is using flash.net.Socket to connect to a server. But there could be a situation when the server is not running, hence nothing is listening on the port socket is connecting to. When I do "telnet hostname port" I get a fast connection refused error. But flash.net.Socket does not invoke any event (see below),...

Open ports in android

How to open a port in android, in J2ME is Connector.open thanks in advance ...

java.net.SocketException Connection timed out error

I am getting below error when I am trying to connect to a TCP server. My programs tries to open around 300-400 connections using diffferent threads and this is happening during 250th thread. Each thread uses its own connection to send and receive data. java.net.SocketException: Connection timed out:could be due to invalid address at...

PONG Response to PING - Simple IRC Bot

I am writing a simple IRC Bot in C++. I am having issues, however, parsing "PING" properly. I cannot seem to extract the "PING" string from the output. I have a sample program setup (statically) with the same setup as my IRC bot and I can parse the string, but it does not seem to write properly when I actually apply the method to the bot...

How do I retrieve an error string from WSAGetLastError()?

I'm porting some sockets code from Linux to Windows. In Linux, I could use strerror() to convert an errno code into a human-readable string. MSDN documentation shows equivalent strings for each error code returned from WSAGetLastError(), but I don't see anything about how to retrieve those strings. Will strerror() work here too? How ...

getpeername sa_data

I want to get the IP address of the socket that's connected to my server socket. I've included my code. The sa_data doesn't return char[14] of the type "xxx.xxx.xxx.xxx". Instead, it returns [11][1][xxx][xxx][xxx][xxx][][][][][][][]...[]. Can anyone help? int InitialResult; char SendMessage[1024]; char ReceiveMessage[1024]; WSADATA ...

Simple Sockets in Objective-C

Hey guys, I've had trouble finding simple guides/examples for basic sockets in Objective-C (using NSSocketPort with NSFileHandle or using CFSocket/CSNetwork). Can anyone recommend a guide or a useful example? I would appreciate this greatly! I have tried to use this, but it is incomplete. Thanks! P.S. I have been stuck in this part of ...

Half-Open TCP Connections limit on windows XP SP2

Does the Windows XP SP2 limit of 10 half-open connections refers only to embryonic connections or also to the other known type of half-open connection which happens when one side has crashed? Thanks.. ...

tcp/ip sockets on gprs modem

i want to establish a TCP/IP socket connection between a device connected to gprs modem and another device that is also connected to gprs modem.both devices are connected to gprs via sims.now for tcp/ip socket connection how a client can get destination ip address of server in order to establish connection with it that is listening to t...

bind() error with errno == ENOENT ?

Can anyone help explain what an errno value of ENOENT means when the bind() socket function fails? The man page says this means "the file does not exist". What file? I tried calling bind() with a bad file descriptor and that sets errno to EBADF as expected, so it's not that. ...

How to reliably tell when finished reading from a socket in Java?

We are integrating with an external product that requires us to communicate with it using Java sockets. We've been able to read small responses from the server with no issues, but larger responses are causing some headaches. I made some changes to the socket handling logic and now we seem to be able to read large responses 90% of the tim...

Avira Antivirus detects the listen function as backdoor model

The function listen( ListenSocket, SOMAXCONN ) is detected by avira antivirus as a backdoor model. How can I write small client/server applications without a listen function? Is there a way to do it? ...