Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

sockets

Posted on 2005-04-01
5
Medium Priority
?
272 Views
Last Modified: 2011-04-14
I wrote a program in php that connects to a server using a socket connection, sends a string and then prints to the screen what the server sends back... but I don't know how to do that in VB.NET... cab someone please help ?

Thanks alot!
0
Comment
Question by:pugandjody
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 189 total points
ID: 13687040
http://www.microsoft.com/downloads/details.aspx?familyid=08e3d5f8-033d-420b-a3b1-3074505c03f3&displaylang=en

Download file VisualBasic.msi and install it. See asynchronous client-server sockets programming sample.
0
 
LVL 10

Assisted Solution

by:makerp
makerp earned 186 total points
ID: 13696938
Dim lipa As IPHostEntry = Dns.Resolve("host")
        Dim lep As New IPEndPoint(lipa.AddressList(0), 10000)

        Dim s As New   Socket  (lep.Address.AddressFamily,   Socket  Type.Stream, ProtocolType.Tcp)

        Dim msg As String = "This is a test" & Chr(10)

        Try
            ' Sends datagram to the IpEndPoint specified.  This call blocks.  
            s.SendTo(msg, 0, msg.Length,   Socket  Flags.None, lep)

            ' Creates an IpEndPoint to capture the identity of the sending host.
            Dim sender As New IPEndPoint(IPAddress.Any, 0)
            Dim tempRemoteEP As EndPoint = CType(sender, EndPoint)

            ' Creates a byte buffer to receive the message.
            Dim buffer(1024) As Byte

            ' Receives datagram from a remote host.   This call blocks.
            s.ReceiveFrom(buffer, 0, 100,   Socket  Flags.None, tempRemoteEP)

            ' Displays the information received to the screen.
            Label1.Text = " I received the following message : " & Encoding.ASCII.GetString(buffer)

        Catch e As Exception
            Label2.Text = "Exception : " & e.ToString()
        End Try
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question