Winsock / Sockets 
Author Message
 Winsock / Sockets

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



Fri, 16 Jul 2004 00:38:31 GMT  
 Winsock / Sockets
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()


Quote:
> 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



Fri, 16 Jul 2004 08:57:32 GMT  
 Winsock / Sockets
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



Fri, 16 Jul 2004 09:27:54 GMT  
 Winsock / Sockets
Hi Eli,
Just check your events in declaration panel in code.
Thy have slightly changed the names....Nothing else...
Actually I dont have IDE rightnow...otherwise I can tell you..
Just choose the class name in Codewindow and then check all Methods..

You will get to know...If any help, mail me...or post.

Sachin


Quote:
> 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



Fri, 16 Jul 2004 14:06:30 GMT  
 Winsock / Sockets

Hello,

My name is Jian-Wei Yu. Thank you for using the Microsoft VB Newsgroups.

Do you call the following command:

listener.Bind(localEndPoint)
listener.Listen(100)

You can find the socket sample at:
<FrameworkSDK>\Samples\Applications\WinTalk

Hope it helps. If you have any questions, please reply to this post.

Best Regards,  

Jian-Wei Yu
Microsoft Support

This posting is provided "AS IS" with no warranties, and confers no rights.



Fri, 16 Jul 2004 14:33:40 GMT  
 Winsock / Sockets
Thanks for the prompt reply

I did tried to use the sample code
(FrameworkSDK>\Samples\Applications\WinTalk)

it's looks like the functionality is what I need
I tried to copy parts of the code into my code but with no success
I'm getting errors on the "endpoint" object and the logic is not clear to
me.

Program Info:
my client part is a stand alone listener that's wait for a connection from
the server
while he waits the program needs to run.

my server part includes an abstract object that represent the client
includes:
tcpip communication, retry (if the client is offline), etc..

each client object in the server opens one connection to a corresponding
client program
each client in my server needs to run in a new Thread.

each part (Server / Client) can send and receive data using network.stream /
string

can someone provide me with a sample that represent this behavior
or any reference that is easy to understand.

Thanks
Eli


Quote:
> 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



Fri, 16 Jul 2004 22:44:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Winsock Sockets

2. Memory used by Winsock sockets

3. Winsock Sockets

4. Winsock Sockets

5. Winsock Sockets

6. Winsock Socket Error from embedded VB Form

7. .NET Socket vs VB6 Winsock problem!

8. Visual Basic 4 Socket communication (WinSock) Need Help!

9. Socket flushing in VB (winsock)

10. Winsock.bas Closing Socket?

11. Winsock DataArrival, socket closing and can't GetData before receiving all the data

12. VB5 Winsock to Perl Unix Socket Question

 

 
Powered by phpBB® Forum Software