summaryrefslogtreecommitdiff
path: root/src/udp.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-15 12:41:22 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-15 12:41:22 +0000
commit6038f9434f1eb40caf7992ece9a3972e95a9fc11 (patch)
tree6d99a66c5504ee894e15b215291f57e3e551a3e6 /src/udp.c
parentd9e19a0d5ba8a797e12052e29f9c3a945d2331bc (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.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/udp.c b/src/udp.c
index ee8a216..58e7637 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -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);
}