# C++ Socket Problems

**URL:** https://discourse.vtk.org/t/c-socket-problems/1049
**Category:** Support
**Created:** [May 30, 2019, 9:09am UTC](https://discourse.vtk.org/t/c-socket-problems/1049 "2019-05-30T09:09:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tom](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tom](https://discourse.vtk.org/u/tom)
#### Post date: [May 30, 2019, 9:09am UTC](https://discourse.vtk.org/t/c-socket-problems/1049/1 "2019-05-30T09:09:29Z")

</div>

Hi,

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?

Thanks,  
Tom

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](https://discourse.vtk.org/uploads/default/original/1X/8e9dd345a89d0c8a033679db8c451a04e594478c.cpp) (1.1 KB)  
[CMakeLists.txt](https://discourse.vtk.org/uploads/default/original/1X/9ac20f16837f51bcf25e4d9d1bd9c481820673e1.txt) (1.2 KB)  
[Client.cpp](https://discourse.vtk.org/uploads/default/original/1X/fa22c6acf9f935cbc8d1124578e80f214233a3b0.cpp) (1001 Bytes)
