Skip to content
Advertisement

Connection refused – tcp socket in linux [closed]

Ok,

first how to run my program:

JavaScript

my server

JavaScript

How to compile?

server: gcc server.c -o server -lcrypto

client: gcc client.c -o client -lcrypto

You have to create dirr like mydir and put file 1.txt.

How to run?

./server -p 12345 -k ksiegi/

./client -i 127.0.0.1 -o 12345 -k 1 -j2 -c 1 -p 5432 -d XX

What is wrong with my code? First I try to connect with UDP and send data – works great. But after that – I want to use data and create TCP connection and NOW:

Sometimes it is work, sometimes fails. Why? When I am putting port like 5000 -> works, when I am trying 5432 or 5000 my output : Connectron refused.

Any idea? .

Advertisement

Answer

JavaScript

From what I can tell, the port has not been initialized before you call bind. Log the port to be sure that the server is listening on the correct port.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement