[UDP-HTTP] Use error codes from owlps.h

This commit is contained in:
Matteo Cypriani 2011-08-26 11:27:37 +02:00
parent 3fec57b1ae
commit c52321a52b
1 changed files with 9 additions and 5 deletions

View File

@ -110,7 +110,7 @@ int main(int argc, char *argv[])
if (ret) if (ret)
{ {
perror("Cannot create the TCP server thread") ; perror("Cannot create the TCP server thread") ;
ret = 1 ; ret = OWL_ERR_THREAD_CREATE ;
goto exit ; goto exit ;
} }
@ -156,14 +156,14 @@ int receive_udp()
/* Open the UDP socket */ /* Open the UDP socket */
udp_sockfd = owl_create_udp_listening_socket(OWL_DEFAULT_RESULT_PORT) ; udp_sockfd = owl_create_udp_listening_socket(OWL_DEFAULT_RESULT_PORT) ;
if (udp_sockfd < 0) if (udp_sockfd < 0)
return 1 ; return OWL_ERR_SOCKET_CREATE ;
/* UDP read loop */ /* UDP read loop */
while (owl_run) while (owl_run)
{ {
result = owl_receive_position(udp_sockfd) ; result = owl_receive_position(udp_sockfd) ;
if (result == NULL) if (result == NULL)
return 1 ; return OWL_ERR_SOCKET_RECV ;
owl_print_result(result) ; owl_print_result(result) ;
store_result(result) ; store_result(result) ;
printf("--------------\n") ; printf("--------------\n") ;
@ -232,7 +232,7 @@ int init_tcp_socket()
if (tcp_sockfd < 0) if (tcp_sockfd < 0)
{ {
perror("Error opening the TCP socket") ; perror("Error opening the TCP socket") ;
return tcp_sockfd ; return OWL_ERR_SOCKET_CREATE ;
} }
bzero((char *) &server_addr, sizeof(server_addr)) ; bzero((char *) &server_addr, sizeof(server_addr)) ;
@ -245,7 +245,7 @@ int init_tcp_socket()
sizeof(server_addr)) < 0) sizeof(server_addr)) < 0)
{ {
perror("Error binding the TCP socket") ; perror("Error binding the TCP socket") ;
return -1 ; return OWL_ERR_SOCKET_CREATE ;
} }
return 0 ; return 0 ;
@ -319,6 +319,10 @@ void* tcp_server(void *NULL_value)
} }
/*
* Reads a message and search for a request in it.
* Returns the identifier of a request if found, or 0 if not found.
*/
int int
extract_request_from_message(char client_request[CLIENT_REQUEST_STRLEN], extract_request_from_message(char client_request[CLIENT_REQUEST_STRLEN],
char *client_message) char *client_message)