Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. sockets!!

sockets!!

Scheduled Pinned Locked Moved Visual Basic
iossysadminhelptutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ecentinela
    wrote on last edited by
    #1

    I'm trying to make a program that sends data to another computer throught a net. I have follow an example but I can not establish connection. In the sender, I have this code: 'CREAR EL SOCKET Y CONECTAR Dim iphe As IPHostEntry = Nothing iphe = Dns.Resolve(server) Dim ipad As IPAddress = iphe.AddressList(0) ipad = iphe.AddressList(0) Dim ipe As New IPEndPoint(ipad, port) Dim tmpS As New Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp) tmpS.Connect(ipe) '****************************************** 'ENVIAR Dim ASCII As Encoding = Encoding.ASCII Dim envio As String = Me.txtAccion.Text Dim ByteGet As [Byte]() = ASCII.GetBytes(envio) Dim RecvBytes(255) As [Byte] Dim strRetPage As [String] = Nothing tmpS.Send(ByteGet, ByteGet.Length, 0) And in the client pc I have this code: 'CREAR EL SOCKET Y CONECTAR Dim iphe As IPHostEntry = Nothing iphe = Dns.Resolve(server) Dim ipad As IPAddress = iphe.AddressList(0) ipad = iphe.AddressList(0) Dim ipe As New IPEndPoint(ipad, port) Dim tmpS As New Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp) tmpS.Connect(ipe) '****************************************** 'RECIBIR Dim ASCII As Encoding = Encoding.ASCII Dim [Get] As String = "GET / HTTP/1.1" + ControlChars.Cr + ControlChars.Lf + "Host: " + server + ControlChars.Cr + ControlChars.Lf + "Connection: Close" + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf Dim ByteGet As [Byte]() = ASCII.GetBytes([Get]) Dim RecvBytes(255) As [Byte] Dim strRetPage As [String] = Nothing ' Receive the server home page content. Dim bytes As Int32 = tmpS.Receive(RecvBytes, RecvBytes.Length, 0) ' Read the first 256 bytes. strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes) While bytes > 0 bytes = tmpS.Receive(RecvBytes, RecvBytes.Length, 0) strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes) End While MessageBox.Show(strRetPage) Maybe all the code is wrong (sure!). Someone can help me with this? Maybe there is an easy way to make this... I'm sure someone will teach me :)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups