Connector_RAW for server sharing

This commit is contained in:
Thulinma 2010-10-25 23:12:39 +02:00
parent 2274a05b9c
commit 309f727f62
4 changed files with 61 additions and 0 deletions

18
Connector_RAW/Makefile Normal file
View file

@ -0,0 +1,18 @@
SRC = main.cpp ../sockets/sw_base.cpp ../sockets/sw_inet.cpp ../sockets/sw_unix.cpp
OBJ = $(SRC:.cpp=.o)
OUT = Connector_RAW
INCLUDES =
CCFLAGS = -Wall -Wextra -funsigned-char -g
CC = $(CROSS)g++
LD = $(CROSS)ld
AR = $(CROSS)ar
LIBS=
.SUFFIXES: .cpp
.PHONY: clean default
default: $(OUT)
.cpp.o:
$(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@
$(OUT): $(OBJ)
$(CC) $(LIBS) -o $(OUT) $(OBJ)
clean:
rm -rf $(OBJ) $(OUT) Makefile.bak *~

26
Connector_RAW/main.cpp Normal file
View file

@ -0,0 +1,26 @@
#include <iostream>
#include "../sockets/SocketW.h"
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <unistd.h>
#include <fcntl.h>
int main() {
SWUnixSocket mySocket;
std::string input;
std::cin >> input;
input = "/tmp/shared_socket_"+input;
mySocket.connect(input);
char buffer[500000];
int msg;
while(true) {
msg = mySocket.recv(&buffer[0],10000);
if (!std::cout.good()) {exit(0);}
std::cout.write(buffer,msg);
}
// disconnect
mySocket.disconnect();
return 0;
}