?
Solved

sockets

Posted on 2005-04-01
5
Medium Priority
?
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

801 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