Advertisement
obernardovieira

Socket Cliente

Feb 26th, 2013
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.73 KB | None | 0 0
  1. #include <a_samp>
  2. #include <socket>
  3.  
  4. new Socket:clientsocket;
  5.  
  6. main() {
  7.     print("\n----------------------------------");
  8.     print(" Socket Cliente");
  9.     print("----------------------------------\n");
  10. }
  11. public OnGameModeInit() {
  12.     clientsocket=socket_create(TCP);//cria um socket
  13.     if(is_socket_valid(clientsocket))//verifica se criou
  14.     {
  15.         socket_connect(clientsocket, "127.0.0.1",54678);//conecta ao socket server
  16.         socket_send(clientsocket, "Eu sou o socket cliente e conectei ao socket server!\n",24);//envia mensagem
  17.     }
  18.     return 1;
  19. }
  20. public onSocketAnswer(Socket:id, data[], data_len) {//quando receber resposta do socket server
  21.     printf("socketid %d | mensagem %s | total carateres %d",_:id,data,data_len);
  22.     return 1;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement