How to connect client/server in C (Beej's Guide to Network Programming)
c, networking, sockets
Solution
I don't see your servinfo being filled any where in the code
// Server should allow connections from any ip address
serv_info.sin_addr.s_addr = INADDR_ANY;
Also you might need to fill family and port
// Fill server's address family
serv_addr.sin_family = AF_INET;
To need more details, here is a working server i wrote on a forum http://forum.codecall.net/topic/63924-a-simple-tcp-server-using-linux-c-api/
Problem
I am working through a simple tutorial for C network programming found here: https://beej.us/guide/bgnet/html/multi/index.html After reading through it, my plan was to implement a testing client/server program, and then start to play around, modify things, add stuff, etc. I implemented the program found here (the first client/server set dealing with TCP connections): https://beej.us/guide/bgnet/html/multi/clientserver.html Basically, a "server" runs on one machine, and when the client connects, the server just sends "Hello, world!" This works fine when I run both on the same machine and connect to localhost. However, I am unable to connect between different machines (tried on both a Debian and OpenBSD server, no iptables/pf rulesets). The connection just times out, and I'm not really sure why. I can ping and ssh into both. Can anyone, specifically anyone familiar with this tutorial, point me in the right direction? Edit: no X on servers, so no screenshots, but netstat -tlnp | grep 3490 gives me nothing. netstat -an shows tcp connection listening on 3490.