Re: gtk+sockets



Hi Göran and Olexiy,

Göran:

I have tried exactly the same way you suggested. The following are the sequence of statements that I am using

 

int get_data(gpointer data,gint source,GdkInputCondition condition)

{

    char buf[100];

     fd = source;

    read(fd,buff,strlen(buf)*sizeof(char));

    printf("%s",buf);

}

in my button handler

static void button_clicked(GtkWidget widget,gpoitner data)

{

 

sock = socket();

bind();

printf("waiting to receive data\n");

gdk_input_add(sock,GDK_INPUT_READ,(GdkInputFunction)get_data,&cmdinfo);

}

When I execute the above code, the program just keeps waiting for the data printing "waiting to receive data". Even if the other host sends the data this program wont receive it.

Olexiy:

 Olexiy Avramchenko wrote:

Mohan Chirumamilla wrote:

> Hi All,
>
> After trying to use sockets in my gtk application for 4 futile hrs I
> gave up and decided to seek out help from you guys. Here's my problem
>
> I have a button handler which should receive data over a network when
> the button is clicked.
>
Button handler is a callback on "clicked" signal, isn't it ?

> This is how I approached.
>
> I created a socket in the button handler and binded it to an IP
> address and a port.And then I used the recvfrom() statement to receive
> the data. But it will never be executed and the data wont be received.
>
You mean the "callback is never executed" or "callback is executed but
you code in callback isn't working" ?

My callback works but the receiving statement (recvfrom) would ever receive any data. It just keeps waiting on and on.

> The same piece of code works fine when I keep application free from gtk.
>
So your code have to work with gtk too...

Olexiy



Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

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