sockets

How to most efficently handle large numbers of file descriptors?

There appear to be several options available to programs that handle large numbers of socket connections (such as web services, p2p systems, etc). Spawn a separate thread to handle I/O for each socket. Use the select system call to multiplex the I/O into a single thread. Use the poll system call to multiplex the I/O (replacing the sele...

How to create a buffer for reading socket data in C

Using C / C++ socket programming, and the "read(socket, buffer, BUFSIZE)" method. What exactly is the "buffer" I know that char and byte are the same thing, but does it matter how many elements the byte array has in it? Does the buffer need to be able to hold the entire message until the null character? ...

Socket programming: Do some ISP's impose rate-limiting on FTP uploads?

I'm currently trying to debug a customer's issue with an FTP upload feature in one of our products. The feature allows customers to upload files (< 1MB) to a central FTP server for further processing. The FTP client code was written in-house in VB.NET. The customer reports that they receive "Connection forcibly closed by remote host" er...

Java: How do detect a remote side socket close?

How do you detect if Socket#close() has been called on a socket on the remote side? ...

What is the difference between a port and a socket?

This was a question raised by one of the software engineers in my organisation. I'm interested in the broadest definition. ...

Why is it impossible, without attempting I/O, to detect that TCP socket was gracefully closed by peer?

As a follow up to a recent question (http://stackoverflow.com/questions/151590/java-how-do-detect-a-remote-side-socket-close), I wonder why it is impossible in Java, without attempting reading/writing on a TCP socket, to detect that the socket has been gracefully closed by the peer? This seems to be the case regardless of whether one use...

Java HttpURLConnection: Can it cope with duplicate header names?

I am debugging some code in the Selenium-rc proxy server. It seems the culprit is the HttpURLConnection object, whose interface for getting at the HTTP headers does not cope with duplicate header names, such as: Set-Cookie: foo=foo; Path=/ Set-Cookie: bar=bar; Path=/ The way of getting at the headers through the HttpURLConnection(usi...

What types of sockets are available in VxWorks?

Vxworks supports standard IP v4 and IP v6 sockets, but sockets are also used for other purposes. What other types of sockets are available? ...

Why do SocketChannel writes always complete for the full amount even on non-blocking sockets?

Using the Sun Java VM 1.5 or 1.6 on Windows, I connect a non-blocking socket. I then fill a ByteBuffer with a message to output, and attempt to write() to the SocketChannel. I expect the write to complete only partially if the amount to be written is greater than the amount of space in the socket's TCP output buffer (this is what I exp...

How does a Perl socket resolve hostnames under Linux?

I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04) where all tools (nslookup, curl, wget, firefox, etc) are able to resolve addresses. Yet, the following code fails: $s = new IO::Socket::INET( PeerAddr => 'stackoverflow.com', PeerPort => 80, Proto => 'tcp', ); die "Error: $!\n" unless $s; I verifi...

Is it possible to unlisten on a socket ?

Is it possible to unlisten on a socket after you have called listen(fd, backlog)? Edit: My mistake for not making myself clear. I'd like to be able to temporarily unlisten on the socket. Calling close() will leave the socket in the M2LS state and prevent me from reopening it (or worse, some nefarious program could bind to that socket) ...

Problem With Python Sockets: How To Get Reliably POSTed data whatever the browser?

Hello, I wrote small Python+Ajax programs (listed at the end) with socket module to study the COMET concept of asynchronous communications. The idea is to allow browsers to send messages real time each others via my python program. The trick is to let the "GET messages/..." connexion opened waiting for a message to answer back. My probl...

Best Flash Audio/Video + Interactivity server?

I'm looking for suggestions on Flash realtime servers. Currently, we use a combination of Moock's Unity and Red5, but there are a couple problems. First, we are moving to AS3, and Unity only supports AS2. Secondly, Red5 is pretty flaky for us, we'd prefer something more stable. We can't use the official Flash Media Server, it's a bit out...

Tcp/Ip Socket connections in .NET

For my current project, I need to request XML data over a tcp/ip socket connection. For this, I am using the TcpClient class: Dim client As New TcpClient() client.Connect(server, port) Dim stream As NetworkStream = client.GetStream() stream.Write(request) stream.Read(buffer, 0, buffer.length) // Output buffer and return results... ...

Binding a socket to port 80 in ansi c

When I try to bind port 80 to a socket in c, i always get the error, that I don't have permission to use this port. is there an easy way to get this permission? ...

what is the best way to do keep alive socket checking in .NET ?

I am looking for a way to do a keep alive check in .NET. The scenario is for both UDP and TCP. Currently in TCP what I do is that one side connects and when there is no data to send it sends a keep alive every X seconds. I want the other side to check for data, and if non was received in X seconds, to raise an event or so. One way i t...

Making a Nonblocking socket for WinSocks and *nix

In C/C++, how would I turn a blocking socket into a non blocking socket in both WinSocks and *nix; so that select() would work correctly. You can use the pre-processor for the platform specific code. ...

good resource for socket errors?

Where can I find a list of all types of bsd style socket errors? ...

Java: Are concurrent reads and writes possible on a blocking SocketChannel via Object(In|Out)putStreams?

I created an ObjectInputSteam and ObjectOutputStream on a blocking SocketChannel and am trying to read and write concurrently. My code is something like this: socketChannel = SocketChannel.open(destNode); objectOutputStream = new ObjectOutputStream(Channels.newOutputStream(socketChannel)); objectInputStream = new ObjectInputStream(Chan...

Testing socket connection in Python

This question will expand on: http://stackoverflow.com/questions/68774/best-way-to-open-a-socket-in-python When opening a socket how can I test to see if it has been established, and that it did not timeout, or generally fail. Edit: I tried this: try: s.connect((address, '80')) except: alert('failed' + address, 'down') but th...