sockets

Problems with Asynchronous UDP Sockets

Hi, I'm struggling a bit with socket programming (something I'm not at all familiar with) and I can't find anything which helps from google or MSDN (awful). Apologies for the length of this. Basically I have an existing service which recieves and responds to requests over UDP. I can't change this at all. I also have a client within my ...

Why are my sockets only able to communicate client-to-server and not server-to-client?

I have written a simple Java dispatcher with a daemon thread to handle the incoming traffic, and using another thread to send out commands. The problem comes when the server receives the first message, then the client/server system gets stuck on where the server trying to send out a response to the client. The sockets on both end just ...

accept socket from local client on ALL interfaces; rejcct remote client

I need to write a small socket server proxy application that accepts connections from local applications on ALL interfaces (socket should bind to 0.0.0.0). I'm not aware of way to achieve this (I have additional requirements that prevent binding to the 127.0.0.1). A first attempt at this does the following: bind(0.0.0.0) ... s = accep...

java.io.IOException: General socket error

Hi, I am testing a simple socket program which connects to a server in local area network. I am using Blackberry Pearl 8100 simulator to test this.Also tested on 8900 simulator. But did not work on either. The error is displayed as : java.io.IOException: General socket error Is it that networking programs cannot be tested on simulato...

IpEndPoint Problem

The prog in c#: private void listBox1_Click(object sender, EventArgs e) { String data = (String)this.listBox1.SelectedItem; data = data.TrimEnd(new char[] { '\r', '\n' }); try { ip = Dns.GetHostAddresses(data); } catch (SocketException ex) { MessageBox....

closesocket() fails with WSAEOPNOTSUPP

I've got an application using sockets (which I did not write, so bear with me) and when I try to close a socket, closesocket() fails with error WSAEOPNOTSUPP and the socket sticks around...as in, it is not fully deleted. The socket is created as follows: bool Socket::CreateConnection() { int error; struct addrinfo hints; struc...

is it possible to find out if a ruby socket is in state ESTABLISHED or CLOSE_WAIT without actually sending or reading data?

s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) s.connect(Socket.pack_sockaddr_in('port', 'hostname')) ssl = OpenSSL::SSL::SSLSocket.new(s, sslcert) ssl.connect from here on i would like to check in a thread if the ssl connection and the underlying socket is still ESTABLISHED or if it went into CLOSE_WAIT after the default of ...

Properly handling network timeouts on Windows CE

I'm trying perform a relatively basic TCP socket send/receive operation on Windows CE using the .NET Compact Framework. I'm trying set the timeout value so that reads/writes on a slow connection timeout instead of blocking forever. On the full framework I'm able to simply set the ReceiveTimeout and SendTimeout properties on the Socket ...

Linux: socket accept - "Too many open files"

I am working on a school project where I had to write a multi-threaded server, and now I am comparing it to apache by running some tests against it. I am using autobench to help with that, but after I run a few tests, or if I give it too high of a rate (around 600+) to make the connections, I get a "Too many open files" error. After I...

Question about server socket programming model

Hello, Over the last couple of months I've been working on some implementations of sockets servers in C++ and Java. I wrote a small server in Java that would handle & process input from a flash application hosted on a website and I managed to successfully write a server that handles input from a 2D game client with multiple players in C...

How to read huge data in socket and also write into socketchannel

How to read a very big data using DataInputStream of socket If the data is in String format and having a length of more than 1,00,000 characters. Also How to write that big data using SocketChannel in java Thanks Deepak ...

Error occurs when I connect with socket in Python

Nice to meet you. A socket makes a program in Python by Linux (the transmission of a message) ⇒ Windows (the reception), b ut the following errors occur and cannot connect now. Linux, Windows are network connection together, and there is the authority to cut. socket.error: (111, 'Connection refused') Could you help me!? ...

struct ip_mreq dissapears when compiling with -std=c99

On some of our linux boxen compiling with gcc -std=c99 makes struct ip_mreq dissappear (included from netinet/in.h) Is there some other interface we are supposed to use ? ...

C# client-server protocol/model question

I am trying to conceptually work through a model for a client-server socket application I am writing in c# (both client and server). My server will need to handle many clients at once, and preferably multiple requests from a client at once. I have worked out a container for my communication where I will send a fixed length header at t...

C sockets raises error code 22, EINVAL - invalid argument

The example code below works as as a server process. But when I add the line pid_t childpid; below struct sockaddr_in servaddr, clientaddr; it fails at line connectfd = accept(listenfd, (struct sockaddr *) &clientaddr, &clientaddrlen); with the error code 22, EINVAL - invalid argument. I'm new to sockets in C and I couldn't unde...

C# Socket.LocalEndPoint returns 0.0.0.0 on some machines

Why does LocalEndpoint = 0.0.0.0 at this point? According to the docs it should be the appropiate address selected by the system. Note: This only occurrs on some machines. Most machines return the IP Address I would expect. Is this a bug in .NET? using (Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolTyp...

How to determine an invalid CFSocket

Hi Everyone, how can I avoid, to send data via CFSocketSendData to an invalid socket? I've try to determine the socket state with CFSockerIsValid, but this method returns still true when the other side is close. So how can I determine if the socket is valid? In order so avoid Errors. Thank Chris ...

Check Socket File Descriptor is Avaiable?

If I got a file descriptor (socket fd), how to check this fd is avaiable for read/write? In my situation, the client has connected to server and we know the fd. However, the server will disconnect the socket, are there any clues to check it ? ...

unix domain stream sockets sending more data then it should be

I have two simple programs set up that share data through a unix domain socket. One program reads data out of a Queue and sends it to the other application. Before it is sent each piece of data is front-appended by four bytes with the length, if it is less then four bytes the left over bytes are the '^' symbol. The client application t...

When zeroing a struct such as sockaddr_in, sockaddr_in6 and addrinfo before use, which is correct: memset, an initializer or either?

Whenever I look at real code or example socket code in books, man pages and websites, I almost always see something like: struct sockaddr_in foo; memset(&foo, 0, sizeof foo); /* or bzero(), which POSIX marks as LEGACY, and is not in standard C */ foo.sin_port = htons(42); instead of: struct sockaddr_in foo = { 0 }; /* if at least o...