diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-15 12:41:22 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-15 12:41:22 +0000 |
| commit | 6038f9434f1eb40caf7992ece9a3972e95a9fc11 (patch) | |
| tree | 6d99a66c5504ee894e15b215291f57e3e551a3e6 /src/udp.c | |
| parent | d9e19a0d5ba8a797e12052e29f9c3a945d2331bc (diff) | |
- uprava par detialov v setovom mutiplayeri s portokolom UDP
( hlavne monznost synchronizacie dat od servera kazdnych 5 sekund )
git-svn-id: http://opensvn.csie.org/tuxanci_ng@17 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/udp.c')
| -rw-r--r-- | src/udp.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -1,4 +1,5 @@ + #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> @@ -12,6 +13,8 @@ #define BUFSIZE 1000 +#include "main.h" + typedef struct struct_sock_udp_t { int sock; @@ -142,10 +145,22 @@ void getSockUdpIp(sock_udp_t *p, char *str_ip) strcpy(str_ip, inet_ntoa(p->sockAddr.sin_addr)); } +int getSockUdpPort(sock_udp_t *p) +{ + assert( p != NULL ); + return htons(p->sockAddr.sin_port); +} + + void closeUdpSocket(sock_udp_t *p) { + char str_ip[STR_IP_SIZE]; + assert( p != NULL ); + getSockUdpIp(p, str_ip); + printf("close connect from %s:%d\n", str_ip, htons(p->sockAddr.sin_port)); + close(p->sock); destroySockUdp(p); } |