|
-
Jan 29th, 2008, 05:56 AM
#1
Thread Starter
New Member
Sending Data from vb.Net to VB 6.0 winsock
Hi
I have an application in VB 6.0 which acts as a server.. I have an application in .Net (for smart devices) which will act as a client..
Now I need to send data from the client to the server..
Is this possible?
I use winsock in VB 6.0 and Socket class in VB .Net
Please help me with this...
-
Jan 29th, 2008, 07:57 AM
#2
Re: Sending Data from vb.Net to VB 6.0 winsock
Yes, it is possible. Any basic .NET sockets tutorial will teach you how to establish a connection from a client.
A TCP (or UDP, whatever you're using) connection, is still a TCP connection regardless of what programming language you're using.
-
Jan 29th, 2008, 12:08 PM
#3
Re: Sending Data from vb.Net to VB 6.0 winsock
It seems like you might get some slightly unexpected behavior if you are sending strings, though, since .NET defaults to Unicode, which is two bytes per character, while VB6 was ASCII with one byte per character. That's just a matter of making sure both sides are speaking the same language, but it should only be an issue if you are doing certain types of things.
My usual boring signature: Nothing
 
-
Jan 29th, 2008, 01:26 PM
#4
Thread Starter
New Member
Re: Sending Data from vb.Net to VB 6.0 winsock
Thanks for the response Guys.. I have already tried, but its not working... Will get the code and put it up here...
-
Jan 29th, 2008, 01:49 PM
#5
Re: Sending Data from vb.Net to VB 6.0 winsock
In addition to the code, please post the exact wording of any error messages that you are getting, and what line of code is causing the error.
-
Jan 30th, 2008, 06:22 AM
#6
Thread Starter
New Member
Re: Sending Data from vb.Net to VB 6.0 winsock
This is my VB.Net code... I need to run this on Windows mobile 5.0 emulator as I will be using a PDA to communicate with the PC...
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim addr As IPAddress
Dim port As Integer
Dim client As New TcpClient
addr = IPAddress.Parse("192.168.0.20")
port = 10020
Dim endpoint As New IPEndPoint(addr, port)
Dim s As New Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
s.Connect(endpoint)
If s.Connected Then
MsgBox("Connected")
End If
Dim networkStream As NetworkStream = client.GetStream()
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("1")
networkStream.Write(sendBytes, 0, sendBytes.Length)
MsgBox("connection set")
End Sub
Following is the server code that will be on the PC:
Code:
Private Sub Form_Load()
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.LocalPort = 10020
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData dt
If dt = "1" Then
Call Right
End If
End Sub
-
Jan 30th, 2008, 08:25 AM
#7
Re: Sending Data from vb.Net to VB 6.0 winsock
You are creating a new socket, to communicate with 192.168.0.20...
But you are trying to write to the TcpClient's NetworkStream, even though you havent connected the TcpClient to anything yet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|