Results 1 to 4 of 4

Thread: Open Port Socket Exception - Requested Address is Not Valid in it's Context

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    Open Port Socket Exception - Requested Address is Not Valid in it's Context

    Getting Socket Exception Error.. - "The requested address is not valid in its context"

    Code:
    Dim IP As IPAddress = IPAddress.Parse(TextBox3.Text)
    Dim PORT As Integer = 8888
    Dim Listener As New TcpListener(IP, PORT)
    Listener.Start()
    MsgBox("Server Started")
    When I try to run it I get an error that says- System.Net.Sockets.SocketException: 'The requested address is not valid in its context'
    I am going to assume that because I am trying to open a port on my public IP4 address that it is not working because this is not the way to do this and that
    I should be using my Local IP4 address here..?

    I am just confused because of the way I thought the client is supposed to connect to my public IP4 address..
    If I am opening my Local IP4 address and they are connecting to my Public IP4 address..
    How does that work exactly?

    If that is true though then it will not matter if the client connects to my Public IP4 Address, because it will connect the Public To The Local?
    I had assumed that I was supposed to open the Public address and then client connects to me this way..

    I will also assume that since my ISP owns the Public Address that I have no control over it as far as opening ports?
    So I only control my local IP address?

    If anyone could explain what I am doing wrong and how this works as as far as how clients connect to me remotely.. I greatly appreciate it.
    Last edited by DreamWarrior77; Feb 5th, 2022 at 03:29 PM.

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: Open Port Socket Exception - Requested Address is Not Valid in it's Context

    For the sake of example, let your internal IP address on your server be 10.0.0.1 and your external IP address of your internet connection that the server uses be 15.15.15.15.

    On your server, the listening VB code needs to listen at the IP address of 10.0.0.1
    On your internet router, you need to set up port forwarding so that inbound traffic to 15.15.15.15 on port 8888 is forwarded to 10.0.0.1 on port 8888
    Your client software should be connecting to 15.15.15.15 on port 8888

    Note that, in my experience in the past, some ISP's prohibit residential customers from running servers on their home internet connections. So it might be possible that attempts to connect to port 8888 on your IP address will be blocked by the ISP before it even gets to your router if your are a residential customer and your ISP has those restrictions in place.

    Good luck.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    395

    Re: Open Port Socket Exception - Requested Address is Not Valid in it's Context

    Ok Thanks,

    ok well a few things: 1 It does not matter about the port number really since any available port number should technically work for client/server right?
    So if my ISP for some reason blocks 8888 due to this port being used as an alternate http port, I can always just use any available port anyways..

    Another thing is my router is one of these UBee routers which is like hard coded to their service for some God Forsaken reason.
    So when trying to login to it I first am required to login to my Optimum ISP Account.
    I hate this, first off because if anything happens on their end I have no control and as a point I just tried to login into it for the first time and sure enough it says it can not access my router settings at this time..

    Which proves my point of frustration.. Their slow support sucks as well, waiting forever on them for issues like this is something I need to avoid. So now onto my next question.

    If I have another router that I connect from their router can I route my Public IP4 To My Local IP4 Address and use it like this instead of having issues with their router?
    I wanted to just replace theirs to be honest but I think they have it so that the internet and phone is connecting from a coax cable so if replaced I would need to find one that has this connection.
    I figured just take an ETH cable out to my other router and map it thru here instead..
    Last edited by DreamWarrior77; May 4th, 2022 at 02:18 PM.

  4. #4
    Lively Member
    Join Date
    Apr 2022
    Posts
    65

    Re: Open Port Socket Exception - Requested Address is Not Valid in it's Context

    Well your getting the value from a text box
    Try Wrapping the textbox3.text with CStr function
    String is a proper arg I believe

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