UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2002-07-26 11:38 PM

HectorLasso
Administrator
From: Colombia
Registered: 2002-06-12
Posts: 353

Re: 5.4 - How to read ICMP errors from "connected" UDP

6

If the target machine discards the message because there is no process reading on the requested port number, it sends an ICMP message to your machine which will cause the next system call on the socket to return ECONNREFUSED. Since delivery of ICMP messages is not guarenteed you may not recieve this notification on the first transaction.

Remember that your socket must be "connected" in order to receive the ICMP errors. I've been told, and Alan Cox has verified that Linux will return them on "unconnected" sockets. This may cause porting problems if your application isn't ready for it, so Alan tells me they've added a SO_BSDCOMPAT flag which can be set for Linux kernels after 2.0.0.

From: meng

  I feel very lucky to see this faq. I have been looking for it for a long time.
  As you said that "Linux will return them on "unconnected" sockets. This may cause porting problems if your application isn't ready for it". I have this problem.
  But I still have some questions on how to use the flag SO_BSDOCMPAT. It is use in server or client? What are other parameters of setsockopt?
  Thank you very much.

From: meng

I look for man 7 socket, and get the explaination. The 4nd parameter of system call setsockopt() should be 1,and the 5 should be sizeof it. setsockopt() should be called on the client.
Now it works well.
Best regards!

Offline

Board footer

Powered by FluxBB