OpenTCPStream returns 0
Blitz3D Forums/Blitz3D Programming/OpenTCPStream returns 0
| ||
hi everyone. I work on a few Network-Commands for my game. The UDP-Part runs fine, but I have some problems using TCP in the same program. Here is the (simplified) code from the client: Reader=ReadFile("pic.png") tcpstream=OpenTCPStream(BMP_ServerIP,7999) ;,7999) If tcpstream Then Repeat WriteInt tcpstream,ReadInt(Reader) Until Eof(Reader) CloseTCPStream tcpstream CloseFile Reader Endif And here's the (simplified) code from the server: Writer=WriteFile("picx.png") Servertcp=CreateTCPServer(7999) timeout=1500 time=Millisecs() Repeat tcpstream=AcceptTCPStream(Servertcp) If tcpstream<>0 Then time=Millisecs() Repeat Integer=ReadInt(tcpstream) WriteInt(Writer,Integer) Until Integer=0 Exit EndIf Until MilliSecs()-time>timeout And here some things I know about my problem: UDP is using other ports. The "servertcp" exists, the file "pic.png" too. I have tested this program in my LAN. In this LAN I can play games and use other Blitz-programs. Can somebody help me out, please? |
| ||
tcpstream=OpenTCPStream(BMP_ServerIP,7999) ;,7999) Make sure the BMP_ServerIP is a String, not an integer. BMP_ServerIP$ = "xxx.xxx.xxx.xx". I recommend adding the $ to the end of the var to make sure. |
| ||
Thank you VERY much. I worked all time with UDP and saved the IP as an Integer... |
| ||
warning. you are sending a packet for each byte. this is a slow method of sending using TCP. try using WritebyteS instead. with writeBytes you can send several bytes at one packet. MTU size is often 1500 on internet. |