sockets

Unable to understand read() system call

There is a simple Client-Server program. The server is started $./server 5000 The client is also connected to server.. $./client 127.0.0.1 5000 The client enters a string Client has the message "I got your message" displayed on his terminal & server displays the entered string by the client The issue is that when I run client by doi...

How to find out on which internet addresses a java program can listen.

My program needs to listen incoming socket connections (lets agree on port 8765), but it doesn't know which addresses it can bind on a particular machine. Of, course, it could simply to listen to all of them, but it need to send to the client program over a different(slower) channel the addresses which it should try in order to rich me ...

socket.accept error 24: To many open files

I have a problem with open files under my Ubuntu 9.10 when running server in Python2.6 And main problem is that, that i don't know why it so.. I have set ulimit -n = 999999 net.core.somaxconn = 999999 fs.file-max = 999999 and lsof gives me about 12000 open files when server is running. And also i'm using epoll. But after some ti...

How to detect a timeout when using asynchronous Socket.BeginReceive?

Writing an asynchronous Ping using Raw Sockets in F#, to enable parallel requests using as few threads as possible. Not using "System.Net.NetworkInformation.Ping", because it appears to allocate one thread per request. Am also interested in using F# async workflows. The synchronous version below correctly times out when the target hos...

How to host WCF service and TCP server on same socket?

Tooday I use ServiceHost for self hosting WCF cervices. I want to host near to my WCF services my own TCP programm for direct sockets operations (like lien to some sort of broadcasting TCP stream) I need control over URL namespaces (so I would be able to let my clients to send TCP streams directly into my service using some nice URLs ...

Monitor socket with ngrep or perl for activity, then issue command

I'd like to use ngrep and/or perl to monitor the incoming data stream on a socket, then, when the appropriate characters arrive, like in this case, the string "192.168.1.101:8080", input to the data stream a redirect to another ipaddress, such as "192.168.1.102" Is this even possible? ...

Does it make sense to have more than one UDP Datagram socket on standby? Are "simultaneous" packets dropped or queued by the kernel?

I'm coding a networking application on Android. I'm thinking of having a single UDP port and Datagram socket that receives all the datagrams that are sent to it and then have different processing queues for these messages. I'm doubting if I should have a second or third UDP socket on standby. Some messages will be very short (100bytes ...

Socket Communication C#- IP Address

I have a socket application which I can use in local network, at home. I can make them communicate for example from 192.168.x.x to 192.168.y.y ip addresses. What should I do if I want to use the application over internet, from a remote machine, not local. For example which ip addresses should I use if my friend who lives another country...

.NET Sockets Buffer Overflow No Error

I have one thread that is receiving data over a socket like this: while (sock.Connected) { // Receive Data (Block if no data) recvn = sock.Receive(recvb, 0, rlen, SocketFlags.None, out serr); if (recvn <= 0 || sock == null || !sock.Connected) { OnError("Error In Receive, recvn <= 0 || sock == null || !sock.Conne...

getnameinfo prototype asks for sockaddr not sockaddr_in ?

The getnameinfo prototype asks for sockaddr but I have only seen examples using sockaddr_in. Can this example be re-written for sockaddr ? sin_family becomes sa_family but what about sin_port and sin_addr ? How are they included in sa_data ? struct sockaddr{ unsigned short sa_family; char sa_data[14]; }; struct soc...

Python socket error on UDP data receive. (10054)

I currently have a problem using UDP and Python socket module. We have a server and clients. The problem occurs when we send data to a user. It's possible that user may have closed their connection to the server through a client crash, disconnect by ISP, or some other improper method. As such, it is possible to send data to a closed sock...

Connect two client sockets

Let's say Java has two kind of sockets: server sockets "ServerSocket" client sockets or just "Socket" Imagine the situation of two processes: X = Client Y = Server The server process Y : has a "ServerSocket", that is listening to a TCP port The client process X : sends a connection request through a "Socket" to Y. Y: Then the acce...

C++ Winsock non-blocking/async UDP socket

Hi all! I'm developping a little data processor in c++ over UDP sockets, and have a thread (just one, and apart the sockets) that process the info received from them. My problem happens when i need to receive info from multiple clients in the socket at the same time. How could i do something like: Socket foo; /* init socket vars and ...

An existing connection was forcibly closed by the remote host

I am working with a commercial application which is throwing a SocketException with the message, An existing connection was forcibly closed by the remote host This happens with a socket connection between client and server. The connection is alive and well, and heaps of data is being transferred, but it then becomes disconnected out of...

Socket Read In Multi-Threaded Application Returns Zero Bytes or EINTR (104)

Hi. Am a c-coder for a while now - neither a newbie nor an expert. Now, I have a certain daemoned application in C on a PPC Linux. I use PHP's socket_connect as a client to connect to this service locally. The server uses epoll for multiplexing connections via a Unix socket. A user submitted string is parsed for certain characters/words ...

C# performance methods of receiving data from a socket?

Lets assume we have a simple internet socket, and its going to send 10 megabytes (because i want to ignore memory issues) of random data through. Is there any performance difference or a best practice method that one should use for receiving data? The final output data should be represented by a byte[]. Yes i know writing an arbitrary a...

[Android] SocketException (The system call was cancelled)

Hi. I am working on a android project and I need to connect the gPhone with the PC using UDP socket. The same operation, sending a message to from gPhone to the PC, returns different results in different time: Sometimes succeeded and sometimes throws a SocketExcepton(The system call was cancelled). Can anyone tell me what possibly result...

The behavior of send() and recv() in socket communication

The following is the setup: Server Client | | accept connect | | v | send msg1-> | | | v v recv <- send | | v v send msg2-> recv | | v v close He...

Is there a limitation on the number of sockets being used in any application?

Is there a limitation on the number of sockets being used in any application? In our application for record locking purpose we are handling all the connected users in a middle layer which sometimes get crashed when more number of users are connected to that. ...

How do I reuse a previously-opened port, using SBCL's sockets?

Creating a server-side socket will fail if I'm trying to use the same port I've used before. An address-in-use error occurs. (make-instance 'sb-bsd-sockets:inet-socket :type :stream :protocol :tcp) How do I stop this from happening? Hints and code snippets very welcome! (CL newbie here.) Thanks! ...