Is `/ tmp` the right place for UNIX socket files?

When using UNIX sockets for IPC communication, a file must be created in the file system. Many examples out there on the Internet suggest /tmp as a good place to place sockets in. Some suggest to use /tmp/specific_folder with 700 permissions to keep

non-blocking writing in c

I have read some materials about socket programming online. By default, write() is blocking. In some materials, write() only blocks when socket buffer is full. Some other materials say write() is blocked until all the data in the user buffer has been

Random data size recvection management in block-free mode

I'm sure this question has been asked before, and maybe it's just somewhere miles and miles hidden somewhere in Google results or Stackoverflow. But so far I've setup a nonblocking cache server. That does well with small messages or data. But what if

Send a file with Java Sockets, lose data

I'm trying to send a file from a client to a server with Sockets in Java. It works fine when I am testing on the same machine, but when I test across different machines, I lose large chunks of data, resulting in a corrupted file. If I try to send a v

Writing secure server applications with Qt

i have followed the tutorial "Writing Secure Server Applications with Qt" ( but i have the error: CSampleServer.h #ifndef CSAMPLESERVER_H #define CSA

Reading a socket in a while loop

I want to implement the following functionality while (true) { if client sends something process it else wait till something is send } I have tried the following but it didn't work , it process one thing and then stop working can anyone help me? I ha

Why can Java NIO be superior to standard Java sockets?

Recently I was playing with Java sockets and NIO for writing a server. Although it is still not really clear for me why Java NIO could be superior to standard sockets. When writing a server using either of these technologies, in most cases it comes d

Error reading file and sending via sockets

I am reading a file and transferring it to a server in C++. Following is the main part of my code: Client: long Begin; long End; char * block; //Open the file for reading ifstream myfile;, ios::in | ios::binary); //Calculate the dize

Android: Using a socket connection goes through all activities

The basic idea is that when the app starts a class will simply establish a socket connection to server and define output and input streams, those which should be accessed through all different activities that requires interaction so the socket must b

Communication between PHP and JS

I have a import friends button that when clicked loads friends from Facebook which is done through a post request to a php file. Now how would I create a live progress bar? I know how to make the progress bar itself, just not 100% sure how to do comm

Python WebSocket decoding message

So Im making a WebSocket Server in Python for my own purposes and I need to decypher the data recieved from the network. it's all in some jibberjabbish, can anyone help me figure out what it means? while True: data = self.socket.recv(1024) print byte

Prevent getpeername () from returning

I have a Server (A) and a client (B), written in C, running on the same Linux machine. The server binds a port to INADDR_ANY, and the client binds another port to INADDR_ANY. When another client (C), which is running on another Linux machine, connect

Stop the code after a period of time

Possible Duplicate: Stop running the code after 15 seconds I am dealing with the code of a packet sniffer and I just want to make some modifications to it. Now I am trying to edit it so that once I start the program, it will only capture the packets

release argument in the function specified in pthread_create

I am writing a small server which creates a new thread to handle each new connection. I need to pass the socket to the function using the fourth argument of pthread_create. When trying to free the memory used for the socket i get a segfault. The comm

Threading model and scaling for TCP server with epoll

I've read the C10K doc as well as many related papers on scaling up a socket server. All roads point to the following: Avoid the classic mistake of "thread per connection". Prefer epoll over select. Likewise, legacy async io mechanism in unix ma

Flash Sockets in Chat

I hear a lot about people using flash sockets in chat and other long polling apps. Why is flash used in these scenarios?Performance, because Flash provides the developer with Sockets. Using Sockets, you can open a connection and keep it open until th

How can I read in the data of a socket and write it to a file?

What I am trying to do is to read in data from a socket connection then write all of that to a file. My reader and all the related statements are below. Any ideas why it is not working? If you can see a more efficient way to do this that would also b

.net Sockets Basic Discussion

I have never played with .net sockets. I did a couple of things with winsock back in the day. The time has however come to make use of some comms so I am brushing up on .net sockets. Basically, it seems as tho most examples / implementations use the

Socket creation with the same host

In Java, when creating sockets with the same parameters (ignoring the fact that this code will throw a ConnectException): Socket s1 = new Socket("", 7575); Socket s2 = new Socket("", 7575); Is s1 equal to s2? I mean,

Get the domain name from IP

How can I get domain name from IP address. Is it possible? What functions do I have to use? enter code herestruct sockaddr_in saGNI; char hostname[NI_MAXHOST]; char servInfo[NI_MAXSERV]; u_short port = 443; saGNI.sin_family = AF_INET; saGNI.sin_addr.

Delphi Server Socket component

We have a C/S application all written in Delphi (Client and Server-or middleware if you want) For the client part we use Indy. For the server we use DXSock. Since DXSock is dead for a while we are investigating alternatives for the sever part. I want

Python with javascript communication

OK so im using websockets to let javascript talk to python and that works very well BUT the data i need to send often has several parts like an array, (username,time,text) but how could i send it ? I originally though to encode each one in base64 or

How can I send data in binary form on a Java socket?

I've seen lots of examples of sending serialized data over sockets in Java, but all I want is to send some simple integers and a string. And, the problem is I'm trying to communicate these to a binary written in C. So, bottom line: how can I just sen