Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - recvfrom() could not return back even with TimerTimeout: (8 Items)
   
recvfrom() could not return back even with TimerTimeout  
I am doing peer to peer wireless communication with two QNX6.3.2 machines using UDP. sending is okay, but on the 
recvfrom() thread, the program stuck just in the recvfrom() call, and the TimerTimeout(CLOCK_REALTIME, 
_NTO_TIMEOUT_CONDVAR | _NTO_TIMEOUT_MUTEX | _NTO_TIMEOUT_RECEIVE, NULL, &nWait, NULL); could not timeout after 2ms of 
blocking in recvfrom(). Look for your help.

Eric
Re: recvfrom() could not return back even with TimerTimeout  
On Thu, Jul 03, 2008 at 03:28:57AM -0400, Eric Dong wrote:
> I am doing peer to peer wireless communication with two QNX6.3.2 machines using UDP. sending is okay, but on the 
recvfrom() thread, the program stuck just in the recvfrom() call, and the TimerTimeout(CLOCK_REALTIME, 
_NTO_TIMEOUT_CONDVAR | _NTO_TIMEOUT_MUTEX | _NTO_TIMEOUT_RECEIVE, NULL, &nWait, NULL); could not timeout after 2ms of 
blocking in recvfrom(). Look for your help.

Use _NTO_TIMEOUT_SEND | _NTO_TIMEOUT_RECEIVE; or set the socket
to non blocking, receive in a loop until -1 and block in poll().

-seanb
Re: recvfrom() could not return back even with TimerTimeout  
thank you. basically i have two concurrent threads in my program, one server thread for receiving only and one client 
thread for sending only. and each one binds a different socket descriptor to itself.

code snippet for the server thread:

	struct sockaddr_in fromSockaddr;
	socklen_t fromSockaddrLen;
	int recvBytes = 0;
        fromSockaddrLen = sizeof(fromSockaddr);
        recvBytes = recvfrom( serverSockID, (void *)recvBuf, RECV_BUF_LEN, 0, 		(struct sockaddr *)&fromSockaddr, &
fromSockaddrLen );
        .....

and i just wanna the recvfrom() blocked 
thx
Eric
RE: recvfrom() could not return back even with TimerTimeout  
You need to setup "fromSockaddr" properly before you can use them.

memset(&fromSockaddr, 0, sizeof(fromSockaddr));
fromSockaddr.sa_len = sizeof(fromSockaddr);
fromSockaddr.sa_family = AF_INET;
...
 

> -----Original Message-----
> From: Eric Dong [mailto:eric.dongxx@gmail.com] 
> Sent: Thursday, July 03, 2008 9:18 AM
> To: builds-networking
> Subject: Re: recvfrom() could not return back even with TimerTimeout
> 
> thank you. basically i have two concurrent threads in my 
> program, one server thread for receiving only and one client 
> thread for sending only. and each one binds a different 
> socket descriptor to itself.
> 
> code snippet for the server thread:
> 
> 	struct sockaddr_in fromSockaddr;
> 	socklen_t fromSockaddrLen;
> 	int recvBytes = 0;
>         fromSockaddrLen = sizeof(fromSockaddr);
>         recvBytes = recvfrom( serverSockID, (void *)recvBuf, 
> RECV_BUF_LEN, 0, 		(struct sockaddr 
> *)&fromSockaddr, &fromSockaddrLen );
>         .....
> 
> and i just wanna the recvfrom() blocked thx Eric
> 
> _______________________________________________
> Builds
> http://community.qnx.com/sf/go/post10011
> 
> 
Re: RE: recvfrom() could not return back even with TimerTimeout  
thx, i added your snippet, but when no pkts received, recvfrom() still blocks and the timertimeout still does not make 
any effects.

now i came across another problem, as in my previous post, i have server and client thread, now when i just started the 
client thread(only sending out packets) , the machine on the other side could receive it. but when i started the server 
thread, then both two threads gave me the error during execution:
    sendto: Bad file descriptor
    recvfrom: Bad file descriptor

and if i just only started the server thread, still the same error. seems sth wrong with the server thread. but the 
server and client threads on two machines are the same. so what might cause the above errors? thank u.

Eric
RE: RE: recvfrom() could not return back even with TimerTimeout  
Just as a side point, topics such as these which deal with application
issues as opposed to building io-pkt from the repository really belong
in the "general" networking forum rather than here.  We can keep this
one here, but this group is intended for discussions related
specifically to building code from the repository.

	Thanks!
		Robert.


-----Original Message-----
From: Eric Dong [mailto:eric.dongxx@gmail.com] 
Sent: Thursday, July 03, 2008 10:52 AM
To: builds-networking
Subject: Re: RE: recvfrom() could not return back even with TimerTimeout

thx, i added your snippet, but when no pkts received, recvfrom() still
blocks and the timertimeout still does not make any effects.

now i came across another problem, as in my previous post, i have server
and client thread, now when i just started the client thread(only
sending out packets) , the machine on the other side could receive it.
but when i started the server thread, then both two threads gave me the
error during execution:
    sendto: Bad file descriptor
    recvfrom: Bad file descriptor

and if i just only started the server thread, still the same error.
seems sth wrong with the server thread. but the server and client
threads on two machines are the same. so what might cause the above
errors? thank u.

Eric

_______________________________________________
Builds
http://community.qnx.com/sf/go/post10024
Re: RE: recvfrom() could not return back even with TimerTimeout  
On Thu, Jul 03, 2008 at 10:51:39AM -0400, Eric Dong wrote:
> thx, i added your snippet, but when no pkts received, recvfrom() still blocks and the timertimeout still does not make
 any effects.

The following works for me.

#include <sys/neutrino.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <err.h>
#include <stdio.h>

int
main(void)
{
        int             s;
        uint64_t        timeo;
        struct sockaddr sin;
        socklen_t       slen;
        char            c;

        if ((s = socket(AF_INET, SOCK_RAW, 0)) == -1)
                err(1, "socket");

        timeo = 1 * 1000000000;
        TimerTimeout(CLOCK_REALTIME, _NTO_TIMEOUT_SEND | _NTO_TIMEOUT_REPLY,
            NULL, &timeo, NULL);
        slen = sizeof(sin);
        if (recvfrom(s, &c, 1, 0, (struct sockaddr *)&sin, &slen) == -1)
                err(1, "recvfrom");
        return 0;
}


> 
> now i came across another problem, as in my previous post, i have server and client thread, now when i just started 
the client thread(only sending out packets) , the machine on the other side could receive it. but when i started the 
server thread, then both two threads gave me the error during execution:
>     sendto: Bad file descriptor
>     recvfrom: Bad file descriptor
> 
> and if i just only started the server thread, still the same error. seems sth wrong with the server thread. but the 
server and client threads on two machines are the same. so what might cause the above errors? thank u.

Is io-pkt still running?
Re: RE: recvfrom() could not return back even with TimerTimeout  
thx, for the "bad file descriptor", io-net didnot work anymore and all the network cards have stopped working, i traced 
the initial errors when i ran the program, like this is the real problem:

"tcpip: blown stack handling 0x102. See "stacksize" option. " then after this came out the bad file descriptor for 
server and client thread.

my boot script for the network setup:
	/proc/boot/devp-pccard ss -m
	waitfor /dev/pccard 59
	io-net -d ns83815 -p tcpip -p qnet bind=en0
	waitfor /dev/io-net/en0 
	waitfor /dev/socket
	ifconfig en0 *.*.*.* netmask 255.255.0.0
	
	display_msg "configuring adhoc network mode"
	mount -o channel=11,network=mywork,mode=adhoc -T io-net devn-orinoco.so	
	waitfor /dev/io-net/en1
	ifconfig en1 192.168.1.1 netmask 255.255.255.0

thx
Eric