C++ Socket Problems


I’m trying to send vtk data over a very simple client/server interface using sockets. I’d like to use the vtk socket classes for this, but I can’t get them working. I’ve written a simple client program and a simple server program. They can be tested separately (using netcat to form the other end of the connection) or together. The sockets appear to connect properly, but I have problems both sending and receiving data.

When I send data from my client to an nc server, nc receives packages of the correct size (checked with tcpdump) but doesn’t print anything.

When I send data from an nc client to my server, I never receive anything. I’ve tried every combination of settings I can think of, but the system receive call always returns -1.

Can someone point me in the right direction?


Edit: Because I was new to the forum, it wouldn’t let me upload files so I had to post my code as replies. I’ve now spent long enough reading that I’m allowed to upload files, so here you go:

Server.cpp (1.1 KB)
CMakeLists.txt (1.2 KB)
Client.cpp (1001 Bytes)