Merge pull request #332 from metalefty/freebsd/ipv6

common: add log for g_tcp_connect
ulab-next-nosound
jsorg71 9 years ago
commit 8249091183

@ -668,6 +668,7 @@ int APP_CC
g_tcp_connect(int sck, const char *address, const char *port)
{
int res = 0;
char errorMsg[256];
struct addrinfo p;
struct addrinfo *h = (struct addrinfo *)NULL;
struct addrinfo *rp = (struct addrinfo *)NULL;
@ -693,6 +694,12 @@ g_tcp_connect(int sck, const char *address, const char *port)
{
res = getaddrinfo(address, port, &p, &h);
}
if (res != 0)
{
snprintf(errorMsg, 255, "g_tcp_connect: getaddrinfo() failed: %s",
gai_strerror(res));
log_message(LOG_LEVEL_ERROR, errorMsg);
}
if (res > -1)
{
if (h != NULL)
@ -979,8 +986,8 @@ g_tcp_accept(int sck)
ret = accept(sck, (struct sockaddr *)&s, &i);
if(ret>0)
{
snprintf(ipAddr,255,"A connection received from: %s port %d"
,inet_ntoa(s.sin_addr),ntohs(s.sin_port));
snprintf(ipAddr, 255, "A connection received from: %s port %d",
inet_ntoa(s.sin_addr), ntohs(s.sin_port));
log_message(LOG_LEVEL_INFO,ipAddr);
}
return ret ;

Loading…
Cancel
Save