From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E548CBC0B for ; Sat, 6 Jan 2007 17:53:15 +0100 (CET) Received: from cgpmail.ua.pt (frontend-2.servers.ua.pt [193.136.173.3]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l06GrFrP023601 for ; Sat, 6 Jan 2007 17:53:15 +0100 Received: from [84.90.81.151] (account a25285@alunos.det.ua.pt HELO [192.168.0.3]) by frontend-2.cgpmail.ua.pt (CommuniGate Pro SMTP 5.0.10) with ESMTPSA id 44321093 for caml-list@yquem.inria.fr; Sat, 06 Jan 2007 16:53:14 +0000 Message-ID: <459FD3E5.4080409@alunos.det.ua.pt> Date: Sat, 06 Jan 2007 16:52:53 +0000 From: Frederico Valente User-Agent: Thunderbird 1.5.0.9 (X11/20061219) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Udp connection problem References: <459EA5A0.8060000@alunos.det.ua.pt> <459F78AA.4020603@crans.org> In-Reply-To: <459F78AA.4020603@crans.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 459FD3FB.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; icmp:01 bool:01 const:01 struct:01 hostent:01 struct:01 sockaddr:01 hostent:01 endl:01 ntoa:01 endl:01 sockaddr:01 sizeof:01 phane:98 serv:98 Stéphane Glondu wrote: > Frederico Valente a écrit : >> I am trying to communicate with an udp server currently in my computer. >> The problem is that although I can send messages, and they are correctly >> received, I dont get any message back (I should). Running a sniffer I >> get an ICMP Unreacheable (Port Unreacheable) after the server response. > > It sounds like a firewall is filtering your traffic. > Indeed it sounds, but I don't think it is, as I can set up the connection using C++. bool Connection::connect(const char *host, int port ) { struct hostent *host_ent; struct in_addr *addr_ptr; struct sockaddr_in cli_addr ; int sockfd ; m_sock.socketfd = -1 ; if( (host_ent = (struct hostent*)gethostbyname(host)) == NULL) { // if not a string, get information from IP adress. if( inet_addr(host) == INADDR_NONE ) { cerr << "(Connection::connect) Cannot find host " << host << endl; return false ; } } else // get the necessary information from the hostname (string) { addr_ptr = (struct in_addr *) *host_ent->h_addr_list; host = inet_ntoa(*addr_ptr); } // Open UDP socket. if( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { cerr << "(Connection::connect) Cannot create socket " << host << endl; return false ; } // insert the information of the client cli_addr.sin_family = AF_INET ; cli_addr.sin_addr.s_addr = htonl(INADDR_ANY) ; cli_addr.sin_port = htons(0) ; // bind the client to the server socket if(::bind(sockfd, (struct sockaddr *) &cli_addr, sizeof(cli_addr)) < 0) { cerr << "(Connection::connect) Cannot bind local address " << host << endl; return false ; } // Fill in the structure with the address of the server. m_sock.socketfd = sockfd ; m_sock.serv_addr.sin_family = AF_INET ; m_sock.serv_addr.sin_addr.s_addr = inet_addr(host); m_sock.serv_addr.sin_port = htons(port) ; return true; }