Problem Solved - File Descriptor Input



Ok, I have got the thing working, with the help of the
all the people who spared time to discuss the issue.

I was doing everything right, except that I was using
"stdin" as the file descriptor, for which I took the
advice of to "leave the keyboard because it is a
mess." So, I left the keyboard and directly went to
the sockets. And I was able to do what I wanted, ie
Send the data through the sockets and receive at the
other end.

This is what I did.

void myfunc()
{
 int iRet;
 char mesg[101];
 int len=sizeof(myServer);
 iRet = recvfrom(mySocket, mesg, 100, 0, 
             (struct sockaddr *) &myServer, &len);
 g_print(mesg);
}

main()
{
............
gint gdk_input_add( mySocket, GTK_INPUT_READ, 
		(GdkInputFunction)myfunc, NULL)
.............
}

So, now I am receiving the data at the other end
through the socket. Of course, I had to declare
mySocket (socket file descriptor), as global. But I
can also pass it as an argument in the gdk_input_add
function call, instead of passing NULL, as the fourth
argument. I have not tried that, but I think, it is
not a big issue.

I want to thank, Sven Salut for drawing my attention
to Giochannels. I am not sure what is the relationship
between gnome and gtk. I know that gnome depends upon
gtk. But what else, should we program in gnome or gtk?
I want to thank, Dave Benson for his advice.
I want to thank Paul Davis for keeping with me and
replying to all my queries. Paul Davis has also
suggested an excellent method to do the error handling
also. I think, I shall incorporate that also.

Thanks.
shiraz

__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com



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