I am trying to write a cimple TCP client in VB6. I can connect to the server and read the first line (the greeting). After that, I try to send my computer information to the server ("user@host" for now). I dont know if i need to send a return character for my GetData to read the next line or not. Here is my code:
Dim server_greeting As String
Dim ACK As String
Private Sub Form_Load()
'Closes any possible open connection
Sock.Close
'Connects with the server
Sock.Connect
'Message box telling you are connected
MsgBox "Connected"
'Reads the greeting
Sock.GetData server_greeting
'Message box displays the greeting
MsgBox server_greeting
'Sends user@host
Sock.SendData "user@host"
'Reads the ACK
Sock.GetData ACK
'Displays ACK message
MsgBox ACK
'Closes connection
Sock.Close
End Sub
I have the server and port information already entered in the winsock's properties so I dont need to put it into code. Any help will be greatly appreciated. The server is ryker.aet.cup.edu, the port is 44001.
Another problem I was having was after i send the "user@host" to the server. After that message is sent, another acknowledgment is supposed to be sent. Then after that ACK, we are supposed to send the letter "c" that will then spew out a long line of data. Any ideas on how to do that?
Seems like that server wants you to send a vbCrLf after everything you send it, so try that. If that doesn't work, try vbCrLf & vbCrLf
You will need to find out the protocol it uses so you can make your client program communicate with it. You would have to contact the developer of the server to find that out.
If there is another client program already made, you can use a port monitor/packet sniffer to watch what data is being sent/received from client to server and learn the protocol that way.
We are using our own protocol. Basically, we connect to the server, the server sends the greeting and waits for the client to send the user@host. The server then sends back an ACK. Then the server waits for a command (sending the character "c" sends back current weather data).
We are using our own protocol. Basically, we connect to the server, the server sends the greeting and waits for the client to send the user@host. The server then sends back an ACK. Then the server waits for a command (sending the character "c" sends back current weather data).
Well, I tried again and following the steps you described, this is the data I got back, not sure if this is the weather data or not.
When I tried to convert the variable to an integer, it gives me an error saying "Subscript out of range". Is that the right way to change each part of an array?