Well, I'm not a vb.net guru yet, but I believe this is the
translation in VB.NET from C#. Hope it helps! =)
-------------
Dim tcpl as TcpListener = new TcpListener(1000)
tcpl.start()
Dim sck as Socket
Dim read as Byte() = new Byte(2048)
Dim pong as string = "ok"
Dim bytePong as byte() = encoding.ASCII.GetBytes(pong.ToCharArray())
Do While True ' <~~ ??
sck=tcpl.AcceptSocket()
sck.Send(bytePong, bytePong.Length, 0)
dim bytes as int16 = sck.Receive(read, read.Length, 0)
Dim strRead as string = Encoding.ASCII.GetString(read, 0, bytes)
Console.WriteLine(strRead)
sck.Close()
Loop
Quote:
> This is c# instead of vb.net.
> I guess you get some hints because vb.net uses same object with c#.
> TcpListener tcpl = new TcpListener(1000)
> tcpl.Start()
> Socket sck
> Byte[] read = new Byte[2048]
> string pong="ok"
> byte[] bytePong=Encoding.ASCII.GetBytes(pong.ToCharArray())
> while (true)
> sck= tcpl.AcceptSocket()
> sck.Send(bytePong,bytePong.Length,0)
> int bytes = sck.Receive(read, read.Length, 0)
> string strRead = Encoding.ASCII.GetString(read, 0, bytes)
> Console.WriteLine(strRead)
> sck.Close()
> > Hi
> > I am trying to convert code from vb 6 to vb.net
> > I tried to use the socket class instead of the Winsock dll
> > but I'm unable to get the events from the socket class
> > such as Connect, data_arrival, etc..
> > any idea? / sample code
> > Thanks
> > Eli