Meer debugging

This commit is contained in:
Thulinma 2010-11-08 19:26:38 +01:00
parent a770cd9bf3
commit f4a14532cb
2 changed files with 6 additions and 5 deletions

View file

@ -112,7 +112,7 @@ int main(int argc, char ** argv){
if (ready4data){ if (ready4data){
if (!inited){ if (!inited){
//we are ready, connect the socket! //we are ready, connect the socket!
ss = DDV_OpenUnix(streamname.c_str()); ss = DDV_OpenUnix(streamname);
if (ss <= 0){ if (ss <= 0){
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Could not connect to server!\n"); fprintf(stderr, "Could not connect to server!\n");

View file

@ -1,3 +1,4 @@
#include <string>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
@ -11,12 +12,12 @@
bool socketError = false; bool socketError = false;
bool socketBlocking = false; bool socketBlocking = false;
int DDV_OpenUnix(const char adres[], bool nonblock = false){ int DDV_OpenUnix(std::string adres, bool nonblock = false){
int s = socket(AF_UNIX, SOCK_STREAM, 0); int s = socket(AF_UNIX, SOCK_STREAM, 0);
struct sockaddr_un addr; sockaddr_un addr;
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, adres); strncpy(addr.sun_path, adres.c_str(), adres.size()+1);
int r = connect(s, (sockaddr*)&addr, sizeof(struct sockaddr_un)); int r = connect(s, (sockaddr*)&addr, sizeof(addr));
if (r == 0){ if (r == 0){
if (nonblock){ if (nonblock){
int flags = fcntl(s, F_GETFL, 0); int flags = fcntl(s, F_GETFL, 0);