CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Jul 2011
    Posts
    5

    using the internet

    hello everyone,

    I am starting up a new project which is a little complicated. At the moment i am looking at demo code but my software requires the use of many ports as it is a bit of a server,

    here is the beginning of the code i am using:

    Code:
    int recv;
                byte[] data = new byte[1024];
                IPEndPoint ipep = new IPEndPoint(IPAddress.Any,
                                                 14800);
    
                Socket newsock = new Socket(AddressFamily.InterNetwork,
                                            SocketType.Stream, 
                                            ProtocolType.Tcp);
                newsock.Bind(ipep);
                newsock.Listen(20);
                Console.WriteLine("Listening on ports 14800");
                Socket client = newsock.Accept();
                IPEndPoint clientep = (IPEndPoint)client.RemoteEndPoint;
    
                Console.WriteLine("Connected with {0} at port {1}",
                                clientep.Address, clientep.Port);
    In this we see a random port is used after the program connects, i however do not wish for this to happen. i have one main port and i wan't to keep it that way.I guess it is something to do with binding but not sure,

    After this the port is closed and a new port with a higher number is opened(i'll do this later on though)
    Thanks for the help,

    Dave
    Last edited by micr0man; July 16th, 2011 at 10:13 AM.

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