Click here to Skip to main content
15,911,896 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionRe: Use a collection to keep track of numbers already used Pin
bapu288930-Mar-08 1:49
bapu288930-Mar-08 1:49 
GeneralNetwork communication from a mobile device to desktop [modified] Pin
Cory Kimble13-Mar-08 9:58
Cory Kimble13-Mar-08 9:58 
GeneralRe: Network communication from a mobile device to desktop Pin
nlarson1113-Mar-08 10:54
nlarson1113-Mar-08 10:54 
GeneralRe: Network communication from a mobile device to desktop Pin
Cory Kimble13-Mar-08 11:09
Cory Kimble13-Mar-08 11:09 
GeneralRe: Network communication from a mobile device to desktop Pin
nlarson1113-Mar-08 11:12
nlarson1113-Mar-08 11:12 
GeneralRe: Network communication from a mobile device to desktop Pin
Cory Kimble13-Mar-08 11:20
Cory Kimble13-Mar-08 11:20 
GeneralRe: Network communication from a mobile device to desktop Pin
nlarson1113-Mar-08 11:21
nlarson1113-Mar-08 11:21 
GeneralRe: Network communication from a mobile device to desktop Pin
Cory Kimble14-Mar-08 3:40
Cory Kimble14-Mar-08 3:40 
Can you walk me through how Sockets work? Maybe I am trying to do something and it is wrong. This is what I think my code is trying to do. Correct me if I am wrong.

Server Side
Listener code 'Most of this code I found in a book.
Dim localhostAddress As IPAddress = IPAddress.Loopback
        Dim tcpList As New TcpListener(localhostAddress, 2048) 'I just picked a port not already being used. 
        tcpList.Start()
        Do
            Dim tcpcli As TcpClient = tcpList.AcceptTcpClient
            Dim ns As NetworkStream = tcpcli.GetStream
            Dim sr As New StreamReader(ns)
            Dim receivedData As String = sr.ReadLine()
            Dim result As Boolean

            If receivedData <> "" Then
                'Test the received data to see which function to call
                If receivedData = "BUYER" Then
                    result = desktop.getBuyers()
                ElseIf receivedData = "SHIP" Then
                    result = desktop.updateShip()
                ElseIf receivedData = "MOVE" Then
                    result = desktop.updateMove()
                ElseIf receivedData = "PHYINV" Then
                    result = desktop.updatePhyInv()
                End If


               
                'Send result
                SendData(ns, result)

            End If
            sr.Close()
            ns.Close()
            tcpcli.Close()
            If receivedData = "" Then Exit Do
        Loop

        tcpList.Stop()


Client side code I want to send data across a wireless device to my pc to my running application. Is this code on the right track?

<code>Dim sock As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
           Dim ipep As IPEndPoint = New IPEndPoint(IPAddress.Parse("110.156.10.116"), 2048)
           sock.Connect(ipep)
           Dim ns As NetworkStream = New NetworkStream(sock)


           Dim sw As New StreamWriter(ns)
           sw.WriteLine("BUYER")
           sw.Flush()


           Dim result As String = ReadData(ns)
           sw.Close()
           ns.Close()
           If result <> "" Then Exit Do

       Loop
</code>


The above IP for the socket is to my pc. Does the port have to match the one it is going to on the other end?

Any help is appreciated.
GeneralPage Break for report Pin
Chris Dykes13-Mar-08 9:52
Chris Dykes13-Mar-08 9:52 
GeneralRe: Page Break for report Pin
Dave Kreskowiak14-Mar-08 8:15
mveDave Kreskowiak14-Mar-08 8:15 
GeneralRe: Page Break for report Pin
Chris Dykes14-Mar-08 8:20
Chris Dykes14-Mar-08 8:20 
GeneralRe: Page Break for report Pin
Dave Kreskowiak14-Mar-08 9:50
mveDave Kreskowiak14-Mar-08 9:50 
GeneralConfused about ByVal Pin
Kevin Brydon13-Mar-08 6:19
Kevin Brydon13-Mar-08 6:19 
GeneralRe: Confused about ByVal Pin
Christian Graus13-Mar-08 9:57
protectorChristian Graus13-Mar-08 9:57 
GeneralRe: Confused about ByVal Pin
MikeMarq13-Mar-08 10:40
MikeMarq13-Mar-08 10:40 
GeneralRe: Confused about ByVal Pin
Kevin Brydon13-Mar-08 23:14
Kevin Brydon13-Mar-08 23:14 
QuestionOpening database connection Pin
johnjsm13-Mar-08 5:24
johnjsm13-Mar-08 5:24 
GeneralRe: Opening database connection Pin
Christian Graus13-Mar-08 9:58
protectorChristian Graus13-Mar-08 9:58 
QuestionBackground Workers with Asynch TCP Connections [modified] Pin
Chinners13-Mar-08 5:19
Chinners13-Mar-08 5:19 
GeneralVISTA AREO in VB.NET Pin
vbbeg13-Mar-08 4:31
vbbeg13-Mar-08 4:31 
GeneralRe: VISTA AREO in VB.NET Pin
Colin Angus Mackay13-Mar-08 5:06
Colin Angus Mackay13-Mar-08 5:06 
GeneralRe: VISTA AREO in VB.NET Pin
vbbeg13-Mar-08 20:37
vbbeg13-Mar-08 20:37 
GeneralRe: VISTA AREO in VB.NET Pin
Colin Angus Mackay13-Mar-08 23:06
Colin Angus Mackay13-Mar-08 23:06 
Questionrun time error please help Pin
asha_s13-Mar-08 4:06
asha_s13-Mar-08 4:06 
GeneralRe: run time error please help Pin
Chinners13-Mar-08 6:11
Chinners13-Mar-08 6:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.