aqhome: More work on endpoint system. Basically works.
This commit is contained in:
@@ -56,7 +56,7 @@ AQH_MSG_ENDPOINT *AQH_MsgEndpointTcp_new(const char *host, int port)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ep=AQH_MsgEndpoint_new(fd, AQH_MSG_ENDPOINT_ENDPOINTGROUP_NET);
|
||||
ep=AQH_MsgEndpoint_new(fd, AQH_MSG_ENDPOINT_ENDPOINTGROUP_NET, "TCP Server");
|
||||
AQH_MsgEndpoint_SetAcceptedEndpointGroups(ep, AQH_MSG_ENDPOINT_ENDPOINTGROUP_BUS);
|
||||
AQH_MsgEndpoint_AddFlags(ep, AQH_MSG_ENDPOINT_FLAGS_NOMESSAGES);
|
||||
|
||||
@@ -88,13 +88,13 @@ int _setupListeningSocket(const char *host, int port)
|
||||
sk=socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sk<0) {
|
||||
/* socket error */
|
||||
DBG_ERROR(NULL, "socket(): %s", strerror(errno));
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "socket(): %s", strerror(errno));
|
||||
}
|
||||
|
||||
i=1;
|
||||
rv=setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "setsockopt(): %s", strerror(errno));
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "setsockopt(): %s", strerror(errno));
|
||||
close(sk);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
@@ -109,14 +109,14 @@ int _setupListeningSocket(const char *host, int port)
|
||||
|
||||
rv=bind(sk, (struct sockaddr*) &addr, sizeof(addr));
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "bind(): %s", strerror(errno));
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "bind(): %s", strerror(errno));
|
||||
close(sk);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
rv=listen(sk, AQH_MSG_ENDPOINTTCP_BACKLOG);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "listen(): %s", strerror(errno));
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "listen(): %s", strerror(errno));
|
||||
close(sk);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ int _setSocketNonBlocking(int fd)
|
||||
/* get current socket flags */
|
||||
prevFlags=fcntl(fd, F_GETFL);
|
||||
if (prevFlags==-1) {
|
||||
DBG_ERROR(NULL, "fcntl(): %s", strerror(errno));
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "fcntl(): %s", strerror(errno));
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ int _setSocketNonBlocking(int fd)
|
||||
newFlags=prevFlags|O_NONBLOCK;
|
||||
|
||||
if (-1==fcntl(fd, F_SETFL, newFlags)) {
|
||||
DBG_ERROR(NULL, "fcntl(): %s", strerror(errno));
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "fcntl(): %s", strerror(errno));
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ int _handleReadable(AQH_MSG_ENDPOINT *ep, AQH_MSG_ENDPOINT_MGR *emgr)
|
||||
if (rv<0) {
|
||||
if (errno==EAGAIN || errno==EWOULDBLOCK)
|
||||
return GWEN_ERROR_TRY_AGAIN;
|
||||
DBG_ERROR(NULL, "Error on accept(): %s (%d)", strerror(errno), errno);
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on accept(): %s (%d)", strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
newSock=rv;
|
||||
@@ -196,7 +196,7 @@ int _handleReadable(AQH_MSG_ENDPOINT *ep, AQH_MSG_ENDPOINT_MGR *emgr)
|
||||
return rv;
|
||||
}
|
||||
|
||||
newEp=AQH_MsgEndpoint_new(newSock, AQH_MsgEndpoint_GetGroupId(ep));
|
||||
newEp=AQH_MsgEndpoint_new(newSock, AQH_MsgEndpoint_GetGroupId(ep), "TCP Client");
|
||||
AQH_MsgEndpoint_SetFlags(newEp, AQH_MsgEndpoint_GetFlags(ep));
|
||||
AQH_MsgEndpoint_SubFlags(newEp, AQH_MSG_ENDPOINT_FLAGS_NOMESSAGES);
|
||||
AQH_MsgEndpoint_SetAcceptedMsgGroups(newEp, AQH_MsgEndpoint_GetAcceptedMsgGroups(ep));
|
||||
|
||||
Reference in New Issue
Block a user