From 5101ef756a18baf5d7e794d15577fa73ef2a18fa Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 20 Jul 2013 10:39:05 -0400 Subject: Fixed comments in other files as per request of jvrv --- core/network.c | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'core/network.c') diff --git a/core/network.c b/core/network.c index c08b3512..dbe4574c 100644 --- a/core/network.c +++ b/core/network.c @@ -25,12 +25,12 @@ #include "network.h" -//returns current UNIX time in microseconds (us). +/* returns current UNIX time in microseconds (us). */ uint64_t current_time() { uint64_t time; #ifdef WIN32 - //This probably works fine + /* This probably works fine */ FILETIME ft; GetSystemTimeAsFileTime(&ft); time = ft.dwHighDateTime; @@ -48,8 +48,8 @@ uint64_t current_time() } -//return a random number -//NOTE: this function should probably not be used where cryptographic randomness is absolutely necessary +/* return a random number + NOTE: this function should probably not be used where cryptographic randomness is absolutely necessary */ uint32_t random_int() { #ifndef VANILLA_NACL @@ -60,11 +60,11 @@ uint32_t random_int() #endif } -//our UDP socket, a global variable. +/* our UDP socket, a global variable. */ static int sock; -//Basic network functions: -//Function to send packet(data) of length length to ip_port +/* Basic network functions: + Function to send packet(data) of length length to ip_port */ int sendpacket(IP_Port ip_port, uint8_t * data, uint32_t length) { ADDR addr = {AF_INET, ip_port.port, ip_port.ip}; @@ -72,10 +72,10 @@ int sendpacket(IP_Port ip_port, uint8_t * data, uint32_t length) } -//Function to receive data, ip and port of sender is put into ip_port -//the packet data into data -//the packet length into length. -//dump all empty packets. +/* Function to receive data, ip and port of sender is put into ip_port + the packet data into data + the packet length into length. + dump all empty packets. */ int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length) { ADDR addr; @@ -87,8 +87,8 @@ int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length) (*(int32_t *)length) = recvfrom(sock,(char *) data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen); if(*(int32_t *)length <= 0) { - //nothing received - //or empty packet + /* nothing received + or empty packet */ return -1; } ip_port->ip = addr.ip; @@ -97,12 +97,12 @@ int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length) } -//initialize networking -//bind to ip and port -//ip must be in network order EX: 127.0.0.1 = (7F000001) -//port is in host byte order (this means don't worry about it) -//returns 0 if no problems -//TODO: add something to check if there are errors +/* initialize networking + bind to ip and port + ip must be in network order EX: 127.0.0.1 = (7F000001) + port is in host byte order (this means don't worry about it) + returns 0 if no problems + TODO: add something to check if there are errors */ int init_networking(IP ip ,uint16_t port) { #ifdef WIN32 @@ -117,11 +117,11 @@ int init_networking(IP ip ,uint16_t port) #endif srand((uint32_t)current_time()); - //initialize our socket + /* initialize our socket */ sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - //Functions to increase the size of the send and receive UDP buffers - //NOTE: uncomment if necessary + /* Functions to increase the size of the send and receive UDP buffers + NOTE: uncomment if necessary */ /* int n = 1024 * 1024 * 2; if(setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*)&n, sizeof(n)) == -1) @@ -134,28 +134,28 @@ int init_networking(IP ip ,uint16_t port) return -1; }*/ - //Set socket nonblocking + /* Set socket nonblocking */ #ifdef WIN32 - //I think this works for windows + /* I think this works for windows */ u_long mode = 1; - //ioctl(sock, FIONBIO, &mode); + /* ioctl(sock, FIONBIO, &mode); */ ioctlsocket(sock, FIONBIO, &mode); #else fcntl(sock, F_SETFL, O_NONBLOCK, 1); #endif - //Bind our socket to port PORT and address 0.0.0.0 + /* Bind our socket to port PORT and address 0.0.0.0 */ ADDR addr = {AF_INET, htons(port), ip}; bind(sock, (struct sockaddr*)&addr, sizeof(addr)); return 0; } -//function to cleanup networking stuff +/* function to cleanup networking stuff */ void shutdown_networking() { #ifdef WIN32 WSACleanup(); #endif return; -} \ No newline at end of file +} -- cgit v1.2.3