sockets

IS it possible to multiplex socket connections?

IS it possible to multiplex socket connection? I need to establish multiple connections to yahoo messenger and i am looking for a way to do this efficiently without having to hold a socket open for each client connection. so far i have to use one socket for each client and this does not scale well above 50,000 connections. oh, my solu...

Is it better to send 1 large chunk or lots of small ones when using TCP?

After I accept() a connection, and then write() to the client socket, is it better to write all the data you intend to send at once or send it in chunks? For example: accept, write 1MB, disconnect …or… accept, write 256 bytes, write 256 bytes, … n, disconnect My gut feeling tells me that the underlying protocol does this aut...

How to tell if a connection is dead in python

I want my python application to be able to tell when the socket on the other side has been dropped. Is there a method for this? ...

Java Socket : TCP Checksum Incorrect

I'm experimenting w/java sockets. I can connect to a socket and send/receive bytes of data w/o a problem. However I am also sniffing the traffic using wireshark and noticing each packet that comes from the java socket is marked by wireshark as "tcp checksum incorrect." Anyone have any insight? java version "1.6.0_12" Java(TM) SE Runtim...

problem with socket programming in c\c++

#include "stdafx.h" #include <windows.h> #include <winsock.h> #include <stdio.h> int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR IpCmdLine,int nCmdShow) { WSADATA ws; char buf[100]; WSAStartup(0x0101,&ws); sprintf(buf,"%d.%d",HIBYTE(ws.wVersion),LOBYTE(ws.wVersion)); MessageBox(0,buf,"info",0...

In my application, why does readInt() always throw an EOFException?

(Forgive me because I do not write in Java very often.) I'm writing a client-side network application in Java and I'm having an interesting issue. Every call to readInt() throws an EOFException. The variable is of type DataInputStream (initialized as: DataInputStream din = new DataInputStream(new BufferedInputStream(sock.getInputStream(...

In which cases should I close a TCP connection?

I'm currently writing a multi-process network game server (one gatekeeper process which tells players what games are currently running and allows them to create and join games, and a process per game instance). In which cases it would be useful for the gatekeeper to drop TCP connection to the client, and in which cases it should continu...

Is there a way for multiple processes to share a listening socket?

In socket programming, you create a listening socket and then for each client that connects, you get a normal stream socket that you can use to handle the client's request. The OS manages the queue of incoming connections behind the scenes. Two processes cannot bind to the same port at the same time - by default, anyway. I'm wondering ...

How do I send an array of integers over TCP in C?

I'm lead to believe that write() can only send data buffers of byte (i.e. signed char), so how do I send an array of long integers using the C write() function in the sys/socket.h library? Obviously I can't just cast or convert long to char, as any numbers over 127 would be malformed. I took a look at the question, how to decompose int...

Networking with C/C++ in a Windows enviroment

What is the best way to use sockets on the Windows platform? Basic sockets I guess, TCP/IP. Maybe for a chat client, or just for learning. Could someone give me an example of WININET usage? maybe ftpgetfile() ...

Why do I get weird results when reading an array of integers from a TCP socket?

As was suggested in an answer to my last question (How do I send an array of integers over TCP in C?), I tried to send an array of long int, however I may be doing something to break the solution... #define ARRAY_LEN 4 /* I'm using long because the numbers are very large, * but in this example they're small to save space. */ long orig...

When sending an array of int over TCP, why are only the first amount correct?

Following my previous question (Why do I get weird results when reading an array of integers from a TCP socket?), I have come up with the following code, which seems to work, sort of. The code sample works well with a small number of array elements, but once it becomes large, the data is corrupt toward the end. This is the code to send ...

Successive calls to recvfrom() loses data?

I am working on a reliable file transfer program that uses UDP. (for a course in computer networking.) My question is this - well, consider this scenario: Sender has (for example) 12 bytes of data to send. So the sender performs this call: sendto(fd, &buf, 12, 0, (struct sockaddr *)&cliaddr,sizeof(cliaddr)); This sends the 12 bytes...

Exposing a function to other processes

I'm using this piece of code that exposes a simple function using a socket: while (true) { try { ServerSocket serverSocket = new ServerSocket(7070); Socket clientSocket = serverSocket.accept(); String input = (new BufferedReader(new InputStreamReader(clientSocket.getInputStream()))).readLine(); synchronized (this.map)...

iphone SDK: socket client... how do I handle the receive data delegate across different views/classes?

I am writing a controller for an audio server on the iPhone. Each 'view' generally needs to get data from the TCP/IP socket as a client. I have sockets working from one class using the AsyncSocket class. (which, after trying to get a socket client working for more time than I'd like to admit, is a very impressive and helpful class).. ...

C++ sockets library for cross-platform

Want to implement some network capabilities and I wonder what library should one use for cross-platform purposes. Have only java experience in sockets, so google gave a few tutorials using sys/sockets.h, library sockets++ and boosts asio, which all should be crossplatform capable. Basically I want to use tcp and ipv4 (maybe ipv6 later ...

How do I create a TCP server that will accept only one connection at a time?

I'm writing a client-server pair in C++ using Linux sockets. I want the server to listen for a connection, and while one client is connected the server should reject any other clients that try to connect. I tried implementing this by setting the backlog parameter in the listen function to 0 and to 1 and neither one of those values seem...

How to set up a Winsock UDP socket?

I want to create a Winsock UDP socket that only sends data to a client. I want the kernel to choose an available port for me. On the other hand, I want to indicate which local IP to use, since I'm running a few nics. I've tried combing through the maze of socket options, as well as binding with the port in the socket address set to 0 t...

Reading from socket until client sends EOL in C#

I have a basic socket server that looks like this: IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 8000); Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { newsock.Bind(localEndPoint); } catch (Exception e) { //Errors handled } ...

TCP Socket Server Builds Up CLOSE_WAITs Occasionally Over Time Until Inoperable

Hopefully someone can help us as we're reaching as far as investigation can go! We've got a simple asynchronous socket server written in C# that accepts connections from an ASP.NET web application, is sent a message, performs some processing (usually against a DB but other systems too) and then sends a response back to the client. The c...