Browse Source

add possibility to just open a socket without bind or listen or connect

1.0.0
Georg Hopp 11 years ago
parent
commit
fe1cb3bbdb
  1. 9
      Makefile.am
  2. 3
      include/tr/socket.h
  3. 2
      src/socket_init.c

9
Makefile.am

@ -16,5 +16,12 @@ coverage-html:
-$(MAKE) -C tests $(AM_MAKEFLAGS) -k $@ -$(MAKE) -C tests $(AM_MAKEFLAGS) -k $@
endif endif
REGEX_CCLASS=/^[ \t]*\(TR_CLASS\|TR_INTERFACE\)\(([a-zA-Z0-9_]+)/\2/d,definition/
tags: tags:
ctags -R -V --langdef=cclass --langmap=cclass:.h --regex-cclass='/^[ \t]*\(TR_CLASS\|TR_INTERFACE\)\(([a-zA-Z0-9_]+)/\2/d,definition/'
@ctags -R -V --langdef=cclass --langmap=cclass:.h \
--regex-cclass='$(REGEX_CCLASS)'
loc:
@find src/ include/ -not -path testers -and -name "*.[ch]" \
-exec sed '/\/\*/,/\*\//d;/\/\//d' {} \; | wc -l

3
include/tr/socket.h

@ -147,6 +147,9 @@ TR_TcpSocket TR_socketAccept(TR_TcpSocket);
#define TR_socketConnect(socket) \ #define TR_socketConnect(socket) \
(TR_socketInit((socket), TR_socketConnectAction)) (TR_socketInit((socket), TR_socketConnectAction))
#define TR_socketOpen(socket) \
(TR_socketInit((socket), NULL))
#endif // __TR_SOCKET_H__ #endif // __TR_SOCKET_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

2
src/socket_init.c

@ -80,7 +80,7 @@ TR_socketInit(TR_Socket this, TR_socketAction_fptr action)
this->addrlen = current_info->ai_addrlen; this->addrlen = current_info->ai_addrlen;
memcpy(&(this->addr), current_info->ai_addr, this->addrlen); memcpy(&(this->addr), current_info->ai_addr, this->addrlen);
if (0 == action(this)) {
if (! action || 0 == action(this)) {
break; // success / open and bind or open and connect... break; // success / open and bind or open and connect...
} }

Loading…
Cancel
Save