CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 34 of 34
  1. #31
    Join Date
    Jul 2010
    Posts
    13

    Re: Winsock and File Transfers

    I understand that when both the client and server are on the same machine I use 127.0.0.1. I've gotten that to work. My goal though is for it to work when the client and server are on different machines. If the server can only listen on the local host then how does a client connect to the server's local host if the client is on a different machine?

    BTW I've decided to use hInfo.AddressList(0) example given to make it simpler.

  2. #32
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Winsock and File Transfers

    The instances I have shown where I used the
    Code:
     hInfo = Dns.GetHostEntry(Dns.GetHostName)
    for the server
    and
    Code:
    hInfo = Dns.GetHostEntry("Server Machine Name or IP here")
    for the client

    Work on the same machine as well as different machines. I have been using this method or one very similar to it for a very long time at several client locations and many pcs without fail.

    The client method works on PCs, Windows CE devices, Windows Mobile Devices as well as the emulators when configured properly. I even have a few that are using this over wan connections without issue.

    Note in all cases I am using the System.Net.Sockets class and not the TCP client though for connection purposes I would expect this to work with the TCP client as well.

    Also note that on the client I use a varible for the host name that would be contained in a cfg file of sorts so as to make it easy to change as needed.
    Last edited by DataMiser; July 28th, 2010 at 11:04 PM.
    Always use [code][/code] tags when posting code.

  3. #33
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Winsock and File Transfers

    Usually, a ConnectionString variable, so you can switch easily, in one place.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #34
    Join Date
    Jul 2010
    Posts
    13

    Re: Winsock and File Transfers

    It works now. Thanks for your help.

Page 3 of 3 FirstFirst 123

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

Featured