Compare commits

..

No commits in common. 'eeb3a42da8ae9ffa119cbb0275a52c46352361d6' and '63361651f1b3e1ec1bdc666a272acd1ecd631d15' have entirely different histories.

@ -8,9 +8,8 @@ DEFAULT_TCPPORT=6131
DEFAULT_UDPPORT=6131
DEFAULT_SERVER=localhost
CFLAGS=-I./
OBJLIB=network.o udp.o tcp.o unix.o ssl.o json.o webutils.o webserver.o
INCLIB=UDPTCPNetwork.h UDPTCPNetwork-json.h UDPTCPNetwork-webutils.h
OBJLIB=network.o udp.o tcp.o unix.o ssl.o json.o
INCLIB=UDPTCPNetwork.h
DISTNAME=libUDPTCPNetwork-$(VERSION)
ifeq ($(TARGET),)
@ -18,9 +17,7 @@ noconfig: help
endif
all: dep $(TARGET) test-udp test-tcpserver test-tcpclient test-ssl test-json test-webserver
-include .depend
all: dep $(TARGET) test-udp test-tcpserver test-tcpclient test-ssl test-json
help:
echo "set up configuration"
@ -34,9 +31,6 @@ configlinux: clean
configwindows: clean
cp -f Makefile.rules.windows Makefile.rules
test-webserver: $(TARGET) test-webserver.o
$(CXX) test-webserver.o -o $@ -lUDPTCPNetwork -L./ -I./ $(LDFLAGS)
test-tcpserver: $(TARGET) test-tcpserver.o
$(CXX) test-tcpserver.o -o $@ -lUDPTCPNetwork -L./ -I./ $(LDFLAGS)
@ -58,17 +52,17 @@ keygen:
install: $(TARGET)
cp -f $(TARGET) $(PREFIX)/lib/
ln -sf $(PREFIX)/lib/$(TARGET) $(PREFIX)/lib/lib$(OBJLIB_NAME).so
cp -f UDPTCPNetwork*.h $(PREFIX)/include/
ln -s $(PREFIX)/lib/$(TARGET) $(PREFIX)/lib/lib$(OBJLIB_NAME).so
cp -f UDPTCPNetwork.h $(PREFIX)/include/
uninstall:
rm -f $(PREFIX)/lib/$(TARGET)
rm -f $(PREFIX)/lib/lib$(OBJLIB_NAME).so
rm -f $(PREFIX)/include/UDPTCPNetwork*.h
rm -f $(PREFIX)/include/UDPTCPNetwork.h
rebuild: clean all
$(TARGET): $(OBJLIB)
$(TARGET): $(OBJLIB) $(INCLIB)
$(CXX) -shared $(LINKPARAMS) -o $(TARGET) $^ $(LDFLAGS)
if test -f "lib$(OBJLIB_NAME).so.$(VERSION)"; then ln -sf $(TARGET) lib$(OBJLIB_NAME).so; fi
ar rcs lib$(OBJLIB_NAME).a $(OBJLIB)
@ -80,7 +74,6 @@ clean:
rm Makefile.rules -rf
rm test-tcpserver -rf
rm test-tcpclient -rf
rm test-webserver -rf
rm test-json -rf
rm test-udp -rf
rm test-ssl -rf

@ -73,17 +73,12 @@ std::string string_to_lower(std::string s);
std::string string_to_upper(std::string s);
int file_is_readable (const char *fname);
#ifndef UDPTCPNETWORK_DISABLE_DEBUG
void debug_set_logfile (std::string fname);
void _debug (char *srcfile, int srcline, char *srcfunc, char *fmt,...);
void _errorexit (char *srcfile, int srcline, char *srcfunc, char *fmt,...);
#define debug(...) _debug ((char*)__FILE__, __LINE__, (char*)__FUNCTION__, (char*)__VA_ARGS__)
#define errorexit(...) _errorexit ((char*)__FILE__, __LINE__, (char*)__FUNCTION__, (char*)__VA_ARGS__)
#endif
/************************************************************************
*
* udp related functions
@ -233,8 +228,7 @@ public:
};
#endif
#include <UDPTCPNetwork-json.h>
#include <UDPTCPNetwork-webutils.h>
#include "UDPTCPNetwork-json.h"
#endif

@ -13,7 +13,6 @@ using namespace std;
char dnsip[NET_HOSTLEN];
int UDPTCPNetwork_init = 0;
std::string debug_file = "";
//
// convert host and port to sockaddr_in6
@ -96,13 +95,8 @@ std::string string_to_lower(std::string s) {
};
void debug_set_logfile(std::string fname) {
debug_file = fname;
};
#define LEN_TEXT 256
#define DEBUG_TEXT1LEN 4096
#define LEN_TEXT 128
#define DEBUG_TEXT1LEN 2048
#define DEBUG_TEXT2LEN (DEBUG_TEXT1LEN+LEN_TEXT)
void _debug (char *srcfile, int srcline, char *srcfunc, char *fmt,...) {
va_list args;
@ -127,19 +121,20 @@ void _debug (char *srcfile, int srcline, char *srcfunc, char *fmt,...) {
if (tmptr != NULL)
strftime(texttime, LEN_TEXT, "%H:%M:%S", &tmp);
snprintf (text2, DEBUG_TEXT2LEN-1, "%s.%03d %d %s:%d %s %s\n", texttime, tv.tv_usec/1000, pid,
snprintf (text2, DEBUG_TEXT2LEN-1, "%s.%03d %d %s:%d %s %s", texttime, tv.tv_usec/1000, pid,
srcfile, srcline, srcfunc, text1);
printf ("%s", text2);
if (debug_file.length() > 0) {
/*
if (type == 0 || (type & _debuglevel) != 0) {
FILE *f;
printf ("%s\n", text2);
f= fopen(debug_file.c_str(), "a");
f= fopen(DEBUG_FILE, "a");
if (f) {
fprintf (f, "%s\n", text2);
fclose (f);
}
}
*/
};

@ -113,10 +113,7 @@ int SSLSocket::Connect (int sockfd, int block_timeout) {
TimeoutReset();
sslerror = SSL_ERROR_NONE;
if (NewServerCTX() == 0) {
debug ("error on NewServerCTX()\n");
return 0;
}
NewClientCTX();
timeout = block_timeout;
if (sockfd > 0 && block_timeout > 0) {
@ -130,9 +127,6 @@ int SSLSocket::Connect (int sockfd, int block_timeout) {
}
ssl = SSL_new(ctx);
if (ssl == NULL) {
debug ("SSL_new failed\n");
}
SSL_set_fd (ssl, sockfd);
do {
@ -147,20 +141,13 @@ int SSLSocket::Connect (int sockfd, int block_timeout) {
/// @brief
/// @param sockfd
/// @param block_timeout timeout in ms
/// @return 1 on success, 0 on error
int SSLSocket::Accept (int sockfd, int block_timeout) {
int flags, res;
TimeoutReset();
sslerror = SSL_ERROR_NONE;
timeout = block_timeout;
if (NewServerCTX() == 0) {
debug ("error on NewServerCTX()\n");
return 0;
}
NewServerCTX();
if (sockfd > 0 && block_timeout > 0) {
#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
@ -173,9 +160,6 @@ int SSLSocket::Accept (int sockfd, int block_timeout) {
}
ssl = SSL_new(ctx);
if (ssl == NULL) {
debug ("SSL_new failed\n");
}
SSL_set_fd (ssl, sockfd);
do {
res = SSL_accept(ssl);
@ -280,9 +264,6 @@ long int SSLSocket::Read (char *buffer, long int len) {
if (ret == -1) sslerror = SSL_get_error(ssl, -1);
} while (ret == -1 && TimeoutTime() < timeout &&
(sslerror == SSL_ERROR_WANT_READ || sslerror == SSL_ERROR_WANT_WRITE));
if (ret == -1 &&
(sslerror == SSL_ERROR_WANT_READ || sslerror == SSL_ERROR_WANT_WRITE))
ret = 0;
return ret;
};

@ -65,9 +65,6 @@ TCP::TCP(string h, string p) {
};
/// @brief Listen on a specific TCP port for incomming connections.
/// @param port TCP port to listen on
/// @return 1 on success and 0 on error
int TCP::Listen(int port) {
char buffer[NET_BUFFERSIZE];
int err, i;
@ -125,8 +122,6 @@ int TCP::Listen(int port) {
};
/// @brief check for a new connection
/// @return NULL if there is noone connected or a pointer to the TCP connection.
TCP* TCP::Accept() {
fd_set rfds;
struct timeval tv;

Loading…
Cancel
Save