kai.tian2 Posted July 26, 2014 Share Posted July 26, 2014 Socket client; int init() { PlayerSpectator camera = new PlayerSpectator(); camera.setPosition(Vec3(2.0f,0.0f,1.5f)); camera.setDirection(Vec3(-1.0f,0.0f,-0.5f)); engine.game.setPlayer(camera); client= new Socket(SOCKET_STREAM); int c=client.open("127.0.0.1",6000); log.message(" server open------------%d \n",c); // success c=client.connect(); string red=client.readLine(); log.message("===================== server: %s \n",red); thread("ddfor",client); return 1; } void ddfor(Socket cc) { while(1){ // connect is 0 and open is 1 log.message("isconnect %d isopen %d\n",cc.connect(),cc.isOpened()); int r=cc.recv(1024); cc.printf("test"); // success /* add this string temp=cc.readLine(); !!!!! collapse */ log.message(" from ser: %d \n",r); wait; } } I do not know how to read from server 。 just read is Failure Link to comment
azagniy Posted July 29, 2014 Share Posted July 29, 2014 Hi kai. Can you explain your network case? What kind of server do you have? Is it unigine application or something else? And learn socket samples in detail. ("data/samples/systems/socket_0x.cpp"). Link to comment
Recommended Posts