Results 1 to 13 of 13

Thread: Convert This Code From Winsock To Socket

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    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

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Convert This Code From Winsock To Socket

    Plenty of examples of the sockets class in .NET:
    http://www.pscode.com/vb/scripts/Bro...t=Alphabetical

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    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

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    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

  6. #6
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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.

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Convert This Code From Winsock To Socket

    Thread moved to VB.Net forum, at killer7k's request

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: Convert This Code From Winsock To Socket

    Thanks m8

  9. #9
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: Convert This Code From Winsock To Socket

    Thanks Atheist I Will See Your Example
    but Plz Can You Convert me This Code

  11. #11
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    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

  13. #13
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width