osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking refusal of a network connection


> Also, it can be very useful to strace the client process, eg:

Do you find the following background information more helpful
for the desired clarification of unexpected software behaviour?

elfring at Sonne:~/Projekte/Python> LANG=C strace -e trace=network /usr/bin/python3 socket-send_json_data.py --server_id localhost --server_port 37351
Using Python version:
3.7.2 ?
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 3
socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 5
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = 0
sendto(4, "\2\0\0\0\r\0\0\0\6\0\0\0hosts\0", 18, MSG_NOSIGNAL, NULL, 0) = 18
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="hosts\0", iov_len=6}, {iov_base="\310O\3\0\0\0\0\0", iov_len=8}], msg_iovlen=2, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[5]}], msg_controllen=20, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 14
connect(3, {sa_family=AF_INET, sin_port=htons(37351), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
Traceback ?:
?
  File "socket-send_json_data.py", line 17, in send_data
    so.connect((args.server_id, args.server_port))
ConnectionRefusedError: [Errno 111] Connection refused
+++ exited with 1 +++


> You can also strace the running service process:

I do not observe additional function calls for the TCP client connection
attempt here.


> Also, on the service side it isn't enough to create the service socket,
> you also need to do an accept IIRC.

This should be performed by my implementation of the C++ function ?setup?.

Regards,
Markus