sockets

Socket Protocol Fundamentals

Recently, while reading a Socket Programming HOWTO the following section jumped out at me: But if you plan to reuse your socket for further transfers, you need to realize that there is no "EOT" (End of Transfer) on a socket. I repeat: if a socket send or recv returns after handling 0 bytes, the connection has been broken. If the conn...

How would I use a socket to have several processes communicate with a central process?

For my application, I need to have a central process responsible for interacting with many client processes. The client processes need a way to identify and communicate with the central process. Additionally, the central process may not be running, and the client process needs a way to identify that fact. This application will be running...

is it safe to to destroy a socket object while an asyn_read might be going on in boost.ASIO?

In the following code: tcp::socket socket(io_service); tcp::endpoint ep(boost::asio::ip::address::from_string(addr), i); socket.async_connect(ep, &connect_handler); socket.close(); is it correct to close the socket object, or should I close it only in the connect_handler(), resort to shared_ptr to prolong the life of of the socket...

How can I read a UDP segment in Kernel Space?

Hello everyone. I create a module in kernel space that send a UPD segment using socket RAW, but my problem is read the UDP segment from kernel space. I can read the UDP segment from user space, but when I prove to use "sock_recvmsg" from kernel space, I obtain as result -512 Please, help me! ...

Java socket programming - stream get stuck

I am currently working on a simple proxy server, which receives http request from browser, process it, then forward it to the desire web server. I try to get the request from the input stream of the socket connected by the browser, everything is fine except that the stream get stuck after receiving the last block of data. My code is in...

SocketException: address incompatible with requested protocol

I was trying a run a .net socket server code on Win7-64bit machine . I keep getting the following error: System.Net.Sockets.SocketException: An address incompatible with the requested protocol was used. Error Code: 10047 The code snippet is : IPAddress ipAddress = Dns.GetHostEntry("localhost").AddressList[0]; IPEndPoint ...

ThreadAbort not working with readline from a socket

Hi All I implemented a TCP Client using a thread opening a socket to a server and reading data from it in synchronous way. When the line String thisLine = aReadStream.ReadLine(); blocks because there is no data to read from the socket and I try to perform a Thread.Abort to kill the thread ( since it is blocked on that ReadLine() ) I ex...

Dealing with data on multiple TCP connections with epoll

I have an application that is going to work like a p2p-software where all peer are going to talk to each other. Since the communication will be TCP i thought that I could use epool(4) so that multiple connections can be handled. Since each peer will send data very often, I thought that I will establish a persistent connection to each pee...

how to get the IP address and port number from addrinfo in unix c

i need to send some data to a remote server via UDP in a particular port and get receive a response from it. However, it is blocking and I get not response. I needed to check if the addrinfo value that I get from the getaddrinfo(SERVER_NAME, port, &hints, &servinfo) is correct or not. how do i get the ip address and port number from this...

Error receiving in UDP: Connection refused

i am trying to send a string HI to a server over UDP in a particular port and trying to receive a response. however, after i try to get the response using recvfrom() i was stuck in blocking state. i tried using connected udp but i got Error receiving in UDP: Connection refused what could be the reasons for this. the server i not i...

Listening on socket, need to connect to another socket and communicate

I have a PHP script which creates and listens on a port for connections from multiple clients. I need this socket server to also act as a client, and connect to another server. (multiple other servers). All connections need to be able to receive/send data without "locking" up any of the others. ...

Android, Client-Server app, Bad Socket Exception

I have a simple client-server app on android. the android service communicates with the server via tcp sockets. the service sends a simple String to server which works. the server processes the string and sends back an object to the android service. the object implements the serializable interface. the object "leaves" the server successf...

PHP Warning: socket_recvfrom(): Unsupported socket type 774909488

Code Snippet: $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) or die("Could not create socket\n"); $recvsock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n"); socket_bind($recvsock, "192.168.3.149", "49217") or die ("Could not bind"); socket_listen($recvsock); socket_sendto(...

How to do java.net.InetSocketAddress optimization

I found the bottleneck of my program is Class InetSocketAddress. It used almost 90% of the CPU time. ...

UDP and sockets, recvfrom() returning -1 and resource temporarily unavailable

Hi, I'm pretty new at programming and esp network programming so if it's stupid, don't bash too hard please, thanks. I have client and server communicating with diagrams (UDP) in C. client sends 5 msgs and upon receiving msgs, server sends msgs back. receiving and sending messages are great until client has finished receiving the msgs. ...

DNS Client that is written Using C Sockets

Hi am a newbie.. I just want to write DNS client program using C sockets that takes three arguments: a query name (e.g., host name or domain name) and a query type (A, or NS, or MX), and DNS server name. Print out the responses in the answer section of the DNS record received. I know there is a command getaddrinfo.. but I just want to ...

Double UDP socket binding in Linux

In C++, when I run (red alert! pseudo-code) bind(s1, <local address:port1234>) bind(s2, <local address:port1234>) on two different UDP sockets (s1 and s2 each created with a call to socket()) I get problems. In Linux (Ubuntu), the double binding seems to be fine. In Windows, however, the double binding fails, and the call to bind() th...

PHP: Connection: keep-alive problem reading socket data

Trying to write data to a socket and read the response. $packet = "GET /get-database HTTP/1.1\r\n"; $packet .= "Host: 192.168.3.136:3689\r\n"; //$packet .= "Accept-Encoding: gzip\r\n"; $packet .= "Viewer-Only-Client: 1\r\n"; $packet .= "Connection: keep-alive\r\n\r\n"; socket_write($socket, $packet, strlen($packet)); do{ $buf = ""...

how to make the server accept new connection while processing other things in java

I am from Ethiopia so i am sorry for my English I was designing a muiltithread server/client application and the server has its own user interface that keep the list of all connected client the problem is ss = new ServerSocket( port ); while (true) { // Grab the next incoming connection s = ss.accept(); ss.accept(); block the ent...

Sanity Check - Is a Multiplayer Game Server in Java using TCP (ServerSocket) viable?

Hey Guys, Please stop me before I make a big mistake :) - I'm trying to write a simple multi-player quiz game for Android phones to get some experience writing server code. I have never written server code before. I have experience in Java and using Sockets seems like the easiest option for me. A browser game would mean platform indep...