summaryrefslogtreecommitdiff
path: root/src/udp.c
diff options
context:
space:
mode:
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);
}