Ok, I have a problem with the TCP commands. Please assume that i know nothing about TCP because i know nothing :-). I have been working on this for hours and still no luck.
The program is simple. One application that is a server and the other that is a client. I run the server app (the code will be listed below) and then i run the client app. I use the WriteString function to write a line to the server. It works! Then directly underneath the first writeline i put another write line (it can even be the same exact statement) and it will not send it to the server. I have no clue why. Here is the code.
;This is the server program for our game
;Create the TCP server
svr1 = CreateTCPServer (8767)
;Check to see if the server started or not. If not keep retrying
Repeat
If KeyDown(1) Then
End
End If
If svr1 <> 0
Print "The server started."
Else
Print "The server failed to start."
Print "Press any key to retry."
WaitKey
End If
Until svr1 <> 0
;Now that the server started tell the server started tell the user that he or she is
;going into the main program to accept TCP streams.
Print "Now Accepting TCP Streams."
Print "The Information will appear when the client sends"
Print "the information."
;keep running until the escape key is pressed
While Not KeyDown(1)
svrStream = AcceptTCPStream(svr1)
If svrStream Then
Print ReadString(svrStream)
End If
Wend
And now for the client app.
;This is the client application for our game
Global client1
;Start the loop that will repeat untill the user is properly connected
Repeat
;If the user mashes the ESC Key then End the Program
If KeyDown(1) Then
End
End If
;Connect to the TCP server
client1 = OpenTCPStream("127.0.0.1", 8767)
; test to see if it connected properly
If client1 <> 0 Then
Print "Connected
WriteString client1, "Hello"
WriteString client1, Input("Write Message: ")
Else
Print "Failed to Connect "
Print "Press any key to retry"
WaitKey
End If
Until client1 <> 0
WriteString client1, Input("Write Message: ")
WriteString client1, Input("Write Message: ")
WriteString client1, Input("Write Message: ")
;Go into the main loop of of the client application
Print "Starting Messenger"
After hours of trying to figure this out, i think it is time to try to get some help. Please let me know why my program will not let me send more than one group of text to my server. Like i said, I can send one group of text with WriteString, but then i can not send any more. Thank you for your time.
|