Link to home
Start Free TrialLog in
Avatar of lwinkenb
lwinkenb

asked on

Visual basic sockets

I dont know anything about VB programming, so I apologize in advance if something sounds wrong.

I have a friend that is writting a client in VB, and I am writing the server in java.  We are having a tough time getting the client and server to talk to each other.  For some reason, whenever his client sends text to the server, the server receives weird unicode characters in the streams.

For instance if he sends "Client says hello", the server might receive "(clover symbol)   Client(diamond)   says(clover symbol)   hello".  He tells me he is sending a pure ascii string, so what gives?

This is a piece of the code he is using to connect:
wsck1.LocalPort = Rnd(3000) + 1000
wsck1.Connect wsck1.RemoteHost, wsck1.RemotePort

If someone could post some sample code that would simply connect to a socket on a certain port, and send a line of text and listen for a response - that would be great.

I hope I have provided enough info for someone to help me here.  Thanks a lot for your time.
Avatar of RoryR
RoryR

damn, its so easy it herts...

use the winsock component

i recomend using UDP 4 easyness & speed

1 person:

    With Winsock1
        .RemoteHost = ip
        .RemotePort = 2667
    End With

other person:

    With Winsock1
        .RemoteHost = ip
        .Bind 2667
    End With

1 person:

Winsock1.SendData "wow that was hard :-)"

if ive missed nefing out ppl dont hesitate 2 ask :)
Avatar of lwinkenb

ASKER

Cant use UDP, it must be TCP/IP.

I'm also not sure what you mean by the "1 person:", and then the "other person".  Is one the server and one the client?
yup

tcp/ip is slightly more complicated, im going 2 bed, i'll pasted code in sum time
ASKER CERTIFIED SOLUTION
Avatar of EViLWolf
EViLWolf

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, if you want a random local port, set it to 0.
To what I said before, you can define it as anything you want, it all depends on what you want to do... in that case, you needed As String... in file transfer, you need As Byte, etc.