Convert This Code From Winsock To Socket
Hi To all, I am New To Network Programming With Socket
so I Want To Convert This Code To Socket to use it in VB.NET
This is The Server
Code:
Public Class Form1
Dim GotDat As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AxWinsock1.LocalPort = 2999
AxWinsock1.RemotePort = 455
AxWinsock1.Listen()
End Sub
Private Sub win_ConnectionRequest(ByVal requestID As Long)
AxWinsock1.Close()
AxWinsock1.Accept(requestID)
End Sub
Private Sub win_DataArrival(ByVal bytesTotal As Long)
AxWinsock1.GetData(GotDat)
DoActions(GotDat)
End Sub
Private Sub AxWinsock1_ConnectEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxWinsock1.ConnectEvent
End Sub
End Class
'the Module
Module Module1
Public Function DoActions(ByVal x As String)
Select Case x
Case "msgbox"
Msgbox("Hello Testing")
End Select
Return x
End Function
End Module
this Is The Client
Code:
Public Class Form1
Dim ipAddy As String
Private Sub cmdMsgbox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMsgbox.Click
AxWinsock1.SendData("MsgBox")
End Sub
Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click
ipAddy = txtIP.Text
AxWinsock1.Close()
AxWinsock1.RemotePort = 2999
AxWinsock1.RemoteHost = ipAddy
AxWinsock1.LocalPort = 9999
AxWinsock1.Connect()
cmdConnect.Enabled = False
End Sub
Private Sub cmdDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDisconnect.Click
AxWinsock1.Close()
cmdDisconnect.Enabled = False
End Sub
Thanks
Re: Convert This Code From Winsock To Socket
Re: Convert This Code From Winsock To Socket
Thanks DigiRev For The Link
But I Need To Convert My Code
because with this code i get started with winsock & work
so i need the same for socket to get start with it
Thanks
Re: Convert This Code From Winsock To Socket
Quote:
Originally Posted by killer7k
Thanks DigiRev For The Link
But I Need To Convert My Code
because with this code i get started with winsock & work
so i need the same for socket to get start with it
Thanks
It's not much code so if someone here knows .NET well they will probably convert it. I don't, though.
In the meantime, you can find a sockets class tutorial and learn. What you're doing shouldn't be too hard.
Sorry I can't be more help.
Re: Convert This Code From Winsock To Socket
Thanks DigiRev much Appreciated Your Help
I Will Start Learning Socket After i get This Code Converted To Socket
Because its the base for me
hope someone can convert it to me
Thanks
Re: Convert This Code From Winsock To Socket
Quote:
Originally Posted by killer7k
Thanks DigiRev much Appreciated Your Help
I Will Start Learning Socket After i get This Code Converted To Socket
Because its the base for me
hope someone can convert it to me
Thanks
If you don't get any responses here maybe post in the .NET forum or ask a mod to move it there. Good luck.
:wave:
Re: Convert This Code From Winsock To Socket
Thread moved to VB.Net forum, at killer7k's request
Re: Convert This Code From Winsock To Socket
Re: Convert This Code From Winsock To Socket
You will need to use the Tcp classes in the System.Net.Sockets namespace. Ive posted alot of examples in this thread
Re: Convert This Code From Winsock To Socket
Thanks Atheist I Will See Your Example
but Plz Can You Convert me This Code
Re: Convert This Code From Winsock To Socket
Quote:
Originally Posted by killer7k
Thanks Atheist I Will See Your Example
but Plz Can You Convert me This Code
You basically have all the code you need if you watch the thread in the link i supplied. You should try to implement it yourself, and feel free to ask any questions if you dont understand parts of the code.
Re: Convert This Code From Winsock To Socket
Sorry But i Havent Get In Touch
where is Listener.LocalPort or Listener..RemotePort ?
If You Could Help me To Convert This Code
it will be Nice From You
Re: Convert This Code From Winsock To Socket
Quote:
Originally Posted by killer7k
Sorry But i Havent Get In Touch
where is Listener.LocalPort or Listener..RemotePort ?
If You Could Help me To Convert This Code
it will be Nice From You
See post #2 / #8 in that thread, thats a fully working "server application".
I dont have time to convert your code and even if I had Im sorry to say that I dont think I would, seeing as though you have all the code you need in the other thread i mentioned.