Re: [gnet-dev] ip server



On Friday 05 November 2004 01:57, shar0119 yahoo com wrote:

> Now i want to compile the echoserver-async.c file. How
> can i do this?

It should have been compiled when you did 'make'. Isn't there an executable 
binary in the examples folder called 'echoserver-async'? If yes, go there and 
run it:

    % cd examples
    % ./echoserver-async 8765

> Can i keep the echoserver-async.c file in the example
> folder or do i have to move it somewhere.

You can move it anywhere you like. You can compile it manually with

    % gcc -Wall -O2 -g echoserver.c `pkg-config --cflags --libs gnet-2.0`

> Please i am a newbie so advise me step by step so i
> can compile it and run the result program. I want to
> make a server which when receives tcp/ip connection
> will spit out the IP address from where the connection
> is coming from.

The echoserver-gserver example might be more appropriate in that case. Also, 
GServer is much easier to use. Just add a line like this into 
echoserver-gserver.c:

  static void
  ob_server_func (GServer* server, GConn* conn, gpointer user_data)
  {
    if (conn)
      {
+      g_print ("Received connection from %s:%u\n", 
+                   conn->hostname, conn->port);
        gnet_conn_set_callback (conn, ob_client_func, NULL);
        gnet_conn_set_watch_error (conn, TRUE);

(Note that this might print the IP in IPv6 notation; just play around with 
conn->ia).

Cheers 
 -Tim



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