Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 26th, 2007, 04:45 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default Help with Socket Programming (Imar/parsons att.)

I am trying to test socket programming by creating server and client on my local machine, but it gets stuck at port number. I gave 8080, but when I view in Lan Settings of Internet Explorer, the port number is different, I tried both the ports, but couldn't succeed, can you please guide me where do I find the port number to specify?

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
__________________
Regards
Mike
 
Old March 26th, 2007, 06:09 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I am not sure what you mean? Are you asking how to view which port your app is coming over or are you asking how to specifiy the port in code?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old March 26th, 2007, 07:05 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Parsons

Nice to see you today, ok let me explain in short, I'll show you a piece fo code as below:

TCPListener tcpListener = new TCPListener(10);
tcpListener.Start();
Socket socketForClient = tcpListener.Accept();
if (socketForClient.Connected)
{
   blah blah........
}

Here 10 is the port number, I have tried to specify 8080 as well as the port number in my IE (Tools - Internet Options - Connections - LAN Settings - Port Number), but neither works!!!! So how to proceed.

Thanx

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 
Old March 26th, 2007, 07:11 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Good to see you to Mike.

Is this port even open on your machine? Goto Start -> Run -> cmd -> netstat -a

Do you see where port 10 has a status of listening? If you are running winXp have you opened up port 10 on your firewall?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old March 26th, 2007, 08:00 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Parsons,

Port 10 was just an example, I have run the command you gave, it shows a lot of results, just tell me what I have to look specifically for.......thanx

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 
Old March 26th, 2007, 08:08 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Mike,

First off I am going to assume that the server part of your application is running on your machine.

From the MSDN:
Netstat displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). Used without parameters, netstat displays active TCP connections.

So, basically what I am asking is when you run the netstat command do you have an entry there that shows port 10 as listening? (Or whatever port your server application is running on) (You, obviously, have to have your server application running)

The entry would look something similar to this:
PROTO LOCAL ADDRESS Foriegn Address STATE
TCP [yourPCName]:10 [foriegn address] LISTENING

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old March 26th, 2007, 08:28 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

 
Quote:
quote:(Or whatever port your server application is running on) (You, obviously, have to have your server application running)


Parsons, now I am a bit confused, the port of server is the stuff that I am trying to find, I am testing this socket programming application on my local machine that is connected to LAN (like we generally have the set up in offices), I haven't configured anything like server???

Is there anything you can clarify more?

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 
Old March 26th, 2007, 08:36 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ok.

Based on your OP you said that you are creating a Server and Client application. So, somewhere in your Server application you would have a line similar to this:

new TCPListener(10);

This sets up a TCP Listener on port 10 and, when the server application is running, you should see in your netstat window that your machine (in this case it is your server application) is listening on port 10.

Are you testing both the client and server portions of this application on your local machine or is the server portion of the application somewhere else on your network?


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old March 26th, 2007, 08:43 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Parsons, I am testing both server and client from my local machine. First of all, I am trying to listen from the server using TCPListener. As you suggested, I used netstat and found results like this:

  Proto Local Address Foreign Address State
  TCP Mike:http LISTENING
  TCP Mike:epmap LISTENING
  TCP Mike:https LISTENING
  TCP Mike:microsoft-ds LISTENING
  TCP Mike:1038 LISTENING
  TCP Mike:2425 LISTENING
  TCP Mike:2967 LISTENING
  TCP Mike:3389 LISTENING
  TCP Mike:1046 LISTENING
  TCP Mike:1367 LISTENING
  TCP Mike:netbios-ssn LISTENING

here I have removed details from "Foreign Address" column,
but when I try to use any of the above ports, the error below is thrown:

Only one usage of each socket address (protocol/network address/port) is normally permitted.

I have some other addresses too where the state is blank, but when I try to use them, the application keeps on waiting, does not responds.

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 
Old March 26th, 2007, 09:02 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Right, you can't bind to port 80 because you have a webserver lisetning on that port (http) and since all of the above ports are established, you can't attach another process to the port.

I threw this together real quick (very basic)

In a C# application in the form load event I placed this code:
TcpListener server = new TcpListener(10);
server.Start();

I hit F5 and the form loads and the application runs. While the application is running I ran my netstat command and this was my result:

  Proto Local Address Foreign Address State
  TCP pc0021:10 pc0021.cssbehavioral.org:0 LISTENING
  TCP pc0021:http pc0021.cssbehavioral.org:0 LISTENING
<MORE>

That says that port 10 on my PC is open and in a Listening state, obviously my app wont do anything because I haven't provided logic to deal with clients connecting and such. So I am not sure what is going on. One thing that I know is that if your project is on a Remote machine and you are trying to execute the code on your machine, you will get a Sockets exception related to security.

For the application to work (and be debugged for that matter) it has to reside on your local file system and be executed from there as well.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket Programming lisamargaret C# 1 December 18th, 2007 10:20 AM
Advanced help with dropdown items! (parsons, imar) mike_remember ASP.NET 1.0 and 1.1 Professional 1 April 11th, 2007 08:33 AM
Socket Programming ashu_from_india General .NET 0 June 28th, 2005 12:02 PM
Socket programming vinodkalpaka J2EE 0 June 16th, 2005 02:43 AM
Socket Programming chinni Pro PHP 1 August 18th, 2003 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.