[gnet] (no subject)



Hello!
 
I have a little problem.
I cant figure out how to write to the GServer with gnet.
I have read the examples in the source (echoclient/server) and i can make the
GServer read data that is written to the server using telnet, but when i
try to write to the server nothing happen.
The server say that i am connected but the server never gets the data that i try to write, why?
This is parts of my code that shows how i try to do it:
 
I would be very happy if someone could tell me whats wrong.
I have never seen any other good programs using
GServer out there so if you can tell me of any i would be very glad.
Reading more than the example in the source might help me, i dont realy know
until i tried :)
 
 

gint on_button3_clicked(){
 /* Connect to the server */
 
 GConn *connection;
 g_print("Connecting to the server.\n");
 connection = gnet_conn_new("localhost", 3456, ob_client1_func, NULL);
 gnet_conn_connect(connection, 0);
 
 return 0;
}
 
 
 
 
 

static gboolean ob_client1_func(GConn* conn, GConnStatus status, gchar *buffer, gint length, gpointer user_data)
{
 gchar smuck[]="Smuck";
 switch(status)
 {
  case GNET_CONN_STATUS_CONNECT:
  {
    
 
                g_print("Connected to the server.\n");
  gnet_conn_write(conn, smuck, sizeof(smuck), 0);
 

  break; 
  }
 
  case GNET_CONN_STATUS_READ: 
  {
  g_print("GNET_CONN_STATUS_READ\n");
  break;
  }
 
  case GNET_CONN_STATUS_WRITE:
  {
  g_print("Status: GNET_CONN_WRITE from ob_client1_func.\n");
  g_print("The data that should be written now: %s, size %d.\n",buffer, length);   
  break; 
  }
 
  case GNET_CONN_STATUS_CLOSE:
  case GNET_CONN_STATUS_TIMEOUT:
  case GNET_CONN_STATUS_ERROR:
  {
  g_print("Error");
  break;
  }
 }
 return TRUE;
}
 
 
 

 


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