sockets

assignin sockaddr to another changes the addr?!?

While trying the following the address in the second sockaddr changes: /*Stuff*/ sockaddr add1, add2; recvfrom(/*socket*/, /*buffer*/, /*count*/, /*flag*/, &add1, /*fromlen*/); add2 = add1; //The sa_data - part changes O_o... /*Stuff*/ Anyone knows why?... EDIT: 1.I changed the sockaddr to sockaddr_storage which definetly has enou...

How to implement application protocal

Hi all We want to implement a server/client application for internal use. Does anyone have know how to implement an application protocol based on the socket? Best Regards, ...

recv() is not interrupted by a signal in multithreaded environment

I have a thread that sits in a blocking recv() loop and I want to terminate (assume this can't be changed to select() or any other asynchronous approach). I also have a signal handler that catches SIGINT and theoretically it should make recv() return with error and errno set to EINTR. But it doesn't, which I assume has something to do ...

Electronic blackboard C#

Idea: I want to make smth like real time electronic blackboard. Many users have one board at the screen and can draw smth at the same time, and board will update. Implementation: I have multi user Socket server thats allow chatting (blackboard will be new feature), i need when one user drew smth the borad should update to other users(ma...

bi-directional communication using socketpair: hangs reading output from child process

I'm trying to use a socketpair to have a parent process provide input to a child process that execs a different program (e.g., grep) and then read the resulting output. The program hangs in the while loop that reads the output from the program that the child execs.. The child dupes stdin and stdout on to its end of the socketpair and the...

Why my program freezing while I am listening socket

So, here is some code: obj.HOST = "" obj.PORT = int(port.get()) # it's 100% correct PORT number obj.srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) obj.srv.bind((obj.HOST, obj.PORT)) obj.srv.listen(1) obj.sock, obj.addr = obj.srv.accept() class Client(threading.Thread): def __init__(self,from_): if from_.ip.get() =...

Application behaves differently when output is redirected to an NSPipe object?

I have an application which works with sockets and reads / writes data. It uses Foundation framework combined with CFNetwork and stdio. Here is the issue - when it is launched from console (bash shell) it works 100% fine and there is nothing wrong with. However when it is invoked by another application via NSTask madness begins. The who...

java inputStream Freezing

Im trying to run a thread that goes to a socket, grabs the input stream, and reads it. Im creating hundreds of these threads and have set the timeout for reading and yet the thread still stays at the read() line. public void readPack() { socket.setSoTimeout(4*1000); if (socket.isConnected()) { buffer parse = new buffer(); ...

Can a socket be closed from another thread when a send / recv on the same socket is going on?

Can a socket be closed from another thread when a send / recv on the same socket is going on? Suppose one thread is in blocking recv call and another thread closes the same socket, will the thread in the recv call know this and come out safely? I would like to know if the behavior will differ between different OS / Platforms. If yes, h...

Creating a local server visible through firewalls

I have a local server written in C++ listening to inbound TCP connects using plain socket ::accept() and UDP recvfrom(). I have two problems with this that I wish to solve: Can I programatically make Windows let me open the accept socket without it automatically being blocked by the Windows (software) firewall? Are there any ports I ca...

Can't use ServerSocket on Android

I'm trying to listen on a port using ServerSocket on an Android device. I want to be able to connect to this port over WiFi using a computer on the same network. I get no exception when binding it to a port, however when I check netstat it says: Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 ...

How can I organise program, which should have non-blocking connection on Python?

My question is next: I want to write a program which should connect to the same program on the other machine, and both this program should exchange some information. I can't set up non-blocking connection. How can it be? ...

What book should I read to learn about writing server (sockets, TCP) programs in C++/CLI?

I recently finished this book on Managed C++, and found it very interesting... But I realize the topic is woefully out-of-date now, with the advent of C++/CLI. So I'm looking for recommendations on a new book to read, something to update my knowledge of C++ and .NET. I'm especially interested in writing server applications (using socke...

HTTP header 'Connection: Close' not sent by IE

I have a custom HTTP server that implements the HTTP 1.1 protocol. I have no problem using persistent connections, however, I never receive 'Connection: Close' from IE ( I haven't tested other browsers. ) Instead, the 'receive' times out because it seems IE closes the connection. What header from IE should I look for to gracefully clo...

Using WSASend & WSARecv to transfer binary data

I tried the MSDN code edited that, but still the problem is that when I send 271 bytes data, my WSARecv() shows me 542 byte data, which is just duplicate copy. How can I overcome this problem? http://msdn.microsoft.com/en-us/library/ms741688(v=VS.85).aspx http://msdn.microsoft.com/en-us/library/ms742203(v=VS.85).aspx ...

Getting ai_socktype not supported

I had this working previously, but I didn't understand how, so I'm attempting to rewrite a bit of code. Everything seems to be going fine, except when I try to use getaddrinfo(), I'm getting back a result of -7, which translates into the error "ai_socktype not supported". I'm willing to bet it's simply me still getting a handle on poin...

CFStream: User-friendly errors

I need to connect to a remote host and exchange data with some binary protocol. I'm connecting with: CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"whatever.host.com", port, &readStream, &writeStream); Everything is fine, except the error handling. I'm handling NSStreamEventErrorOccurred in my stream's delegate...

C# UDPClient bad throughput

Hi, We have a production system that gathers telemetry data from remote devices. This data is sent at a reasonable frequency and we end up receiving up to thousands of messages a second at peak times. The payload is circa 80 bytes per message. I am starting to do some performance testing of various storage machanisms, but I thought fir...

Can a socket be closed on local end without Close being called?

I'm having a problem where a socket appears to be closing by itself. Here's the (edited) network diagnostic trace: Exiting Socket#62696216::BeginSend() Exiting Socket#62696216::EndSend() Socket#62696216::BeginSend() Exception in the Socket#62696216::BeginSend - An established connection was aborted by the software in your host machi...

How to limit connection in Linux socket programming?

I want to set the maximum of connection. If it more than the maximum, tell the client now server is full and close the socket. How to write code in C ? Thank you. ...