|
-
Aug 17th, 2007, 04:22 PM
#1
Thread Starter
Fanatic Member
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
-
Aug 17th, 2007, 05:10 PM
#2
Re: Convert This Code From Winsock To Socket
-
Aug 17th, 2007, 05:20 PM
#3
Thread Starter
Fanatic Member
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
-
Aug 17th, 2007, 05:55 PM
#4
Re: Convert This Code From Winsock To Socket
 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.
-
Aug 18th, 2007, 07:11 AM
#5
Thread Starter
Fanatic Member
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
-
Aug 18th, 2007, 02:54 PM
#6
Re: Convert This Code From Winsock To Socket
 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.
-
Aug 19th, 2007, 09:28 AM
#7
Re: Convert This Code From Winsock To Socket
Thread moved to VB.Net forum, at killer7k's request
-
Aug 19th, 2007, 09:33 AM
#8
Thread Starter
Fanatic Member
Re: Convert This Code From Winsock To Socket
-
Aug 19th, 2007, 09:57 AM
#9
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
-
Aug 19th, 2007, 10:10 AM
#10
Thread Starter
Fanatic Member
Re: Convert This Code From Winsock To Socket
Thanks Atheist I Will See Your Example
but Plz Can You Convert me This Code
-
Aug 19th, 2007, 12:33 PM
#11
Re: Convert This Code From Winsock To Socket
 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.
-
Aug 19th, 2007, 03:36 PM
#12
Thread Starter
Fanatic Member
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
-
Aug 19th, 2007, 03:44 PM
#13
Re: Convert This Code From Winsock To Socket
 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.
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
|