?
Solved

How do I access Port of different computer?

Posted on 2009-12-29
14
Medium Priority
?
615 Views
Last Modified: 2012-05-08
Hi,

I have a C# Windows Desktop Application and a Java Mobile Application.  I am having both applications talk using Sockets.  When I test my applications on the Java Cell Phone Emulator, the test is successful, my apps talk.  Now I have deployed the Java app into my Symbian s60 device, which is a Nokia E71x, and also supports Wifi.  Using Wifi, I want my Java App to talk to my C# app on my PC.  I am unable to do this.  my Ip is 192.168.1.100 and port is 8221.  The port is allowed through incomming connections and outgoing connections in Firewall.  Still no good.

Any help appreciated!

Thanks in advanced!
Cheers!
0
Comment
Question by:harsimar11
  • 9
  • 4
14 Comments
 
LVL 33

Assisted Solution

by:Todd Gerbert
Todd Gerbert earned 500 total points
ID: 26141602
Can you telnet to your computer on port 8221?  From a command line on your computer try "telnet localhost 8221" and also try "telnet 192.168.1.100 8221", and on another computer on your network try "telnet 192.168.1.100 8221"

If the connection is successful you should just get either a blinking cursor and a blank screen, or whatever information your application sends.  You'll get "connection timed out" if not successful.

Does it work in all three instances?
0
 
LVL 57

Assisted Solution

by:giltjr
giltjr earned 1500 total points
ID: 26141686
Is your phone connected to your internal network via WiFi or is it connected to the Internet?

If connected via the Internet, then the IP address 192.168.1.100 will not work as that is a private internal address only.  You need to configure your Internet router/firewall to forward port 8221 to your PC (192.168.1.100) and then from your phone access the public IP address.  You can find your public IP address by going to:

     http://whatismyipaddress.com/
0
 

Author Comment

by:harsimar11
ID: 26142198
Telnet command is not supported by Windows 7 I guess, because on CMD it returns as 'telnet' is not recognized as internal/external command.  However, from the webrowser of my PC, I am able to talk to my C# application.  I am able to receive the browser information.  But from any other browser, I am not able to.

Points of Interest:
1)  This PC with C# Sockets application, is actually on Wifi itself and is a laptop running Win 7.
2)   The other PC, which is connected thorough same router, except Ethernet wire, has a different ip (192.168.1.193) than my laptop hosting the C# Sockets app, which has 192.168.1.100.

So, to answer Mr. tgerbert's answer, telnet didn't work, but I can tell that from the other PC, I can't talk to my Laptop's port.  Kind of tricky.
And as for Ms. Giltjr's question, I am really sorry, but I really couldn't get what you were saying.  My phone??  I hope the points I have made, might've answered your question.  If not, then please forgive me.

Thanks you!
Cheers!
0
A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

 

Author Comment

by:harsimar11
ID: 26142347
Also, for Ms. giltj, I am using a router and both of my computers and the symbian device are connected using a router.  Except, Laptop is on Wifi and so is the Symbian Device?  I am not that much of a Network IT guy, but all I could do, I did, but it didn't make any difference.

Thanks!
Cheers!
0
 
LVL 57

Assisted Solution

by:giltjr
giltjr earned 1500 total points
ID: 26142729
You are confusing me.  You said you were using a Nokia E71x, right?  That is a smart phone, right?  

At least according to AT&T it is: http://www.wireless.att.com/businesscenter/NokiaE71x/index.jsp

In your second post you stated you have two PC's.  

So, are you using two PC's or are you using a PC and a Nokia E71x?

Which device is the "server"?  If it is a PC running Windows, then you can go to a command prompt and issue the command:

   netstat -an | findstr /c:"8221"

See if you get back a line that has that port and LISTEN on the end.

Whe you say the firewall allows 8221, which firewall?

0
 

Author Comment

by:harsimar11
ID: 26143072
I am sorry if I was confusing, let me clear all this up for you.
I have a network, connected using a router.  I have a Laptop, which is on Wifi connection from the router.  The laptop is also the Server pc, so we'll call it Server PC.  Then I have a Symbian Smartphone device, nokia e71x, which is the client, so we'll call it the Client Device.  The Client Device is also connected to the same network, since it supports Wifi.  Lastly, I have another PC, a desktop, which is also connected to the router, so I will call it the Test PC.  Hope I am not confusing so far.

Server PC (laptop), Client Device (Nokia e71x), and Test PC (desktop).  So, I have all these devices on the same network, connected through the router.  I first build and ran my Java Application (Client) on the Java Cell Phone Emulator and ran my C# Application to listen to port 8221 on 192.168.1.100.  The emulator successfully sent messages to port 8221 on 192.168.1.100.

So now my application was ready, so I deployed into the Client Device, Nokia e71x.  Now, when I ran the Java Application (Client), the C# Application on my laptop (Server), could not receive any of data.

Now, I had tried to visit 192.168.1.100:8221 on the Server PC (laptop) and after visiting the site, my C# application received browser information, so I knew it was working.
Now to test, I went to the Test PC (Desktop) and in the browser I typed 192.168.1.100:8221 and tried visiting the site, but I got an error, webpage not found.

After doing iPConfig on Server PC (Laptop), I found out that the ip was 192.168.1.100 of Server PC.  However, IpConfig on the Test PC resulted with a different IP, 192.168.1.103.  

So, I know that the IP Address of the Symbian device is different as well and that is why it is not able to receive the data.

If you bothered to read all that, thank you very much.  I apologize for writing this and if I am still confusing.

Thank you very much!
Cheers!
0
 

Author Comment

by:harsimar11
ID: 26143080
Also, I am talking about Windows Firewall, since that is the default on my Server PC (laptop).  I opened the port 8221 to receive and send data.  Just created inbound and outbound rules.  

I tried  netstat -an | findstr /c:"8221" on Command Prompt, but didn't get anything back.  Nothing happened, just another command line came.
0
 
LVL 57

Assisted Solution

by:giltjr
giltjr earned 1500 total points
ID: 26143150
O.K., doing

   netstat -an | findstr /c:"8221"

and getting nothing back means you do not have a TCP/IP server application listening on port 8221.  In order to talk to a service using TCP/IP you need to have the server service up, running and listening on the port you want to talk to.

So you need to make sure that you server (meaning the program you wrote) is up and running and listening on that port.  Now, when you wrote the server program did you actually select port 8221 to open?

Every deivce in a IP network has is own unique IP address, that is why your server and your testPC have different IP addresses and of course the phone has a different IP address also.

Think of an IP address as a telephone number, you can't have multiple houses with the same phone number.

However, since the server program is on your laptop, you should be initiating the connection from the phone.  Your program, running on the laptop, should accecpt the connection and it should then know the IP address of the phone.

0
 

Author Comment

by:harsimar11
ID: 26143305
Thanks.  My bad, I didn't have the Server application running.  I was expecting different results, I didn't know you mean't that I had to listen.  After running the application, I get the following after the netstat -an | findstr /c:"8221" command:
TCP      192.168.1.100:8221     0.0.0.0:0                   LISTENING

I had set up TCP/IP Server before.  This is actually my first time creating an application with sockets and the challenge got tougher when I had to create Java App as Client.  I have it done now. :)

And yea, your right!  There can't be multiple Ip Addresses, I forgot about that.  I have been so crazy trying to figure this out, that I've been a little lost with everything.

And lastly, so you want me to use the phone Ip, not the laptop IP??
I'll try that tell you what happens.. :)

Thanks for you help!!
0
 

Author Comment

by:harsimar11
ID: 26143349
I tried using the phone IP, but it was unsuccessful.  
On C# Server app, I got the following error message: The request address is not valid in its context.
On Java Emulator, I got the following error message:  ConnectionNotFound error in socket::open : error = 10061

I really need to get this project fixed, I need it for school.
0
 

Author Comment

by:harsimar11
ID: 26143364
Also, I turned on Telnet Server and Client in WIndows Features and I was able to talk to my application using the command: telnet 192.168.1.100 8221 in command prompt.  That was really cool, but how would be able to do that in my Java App?
0
 

Accepted Solution

by:
harsimar11 earned 0 total points
ID: 26143571
I was able to solve the problem by setting up Port forwarding in Router settings.

Thanks you all for helping me out.  This application now talks to any computer/phone, its really cool :)

Thanks Again!
Cheers!
0
 
LVL 57

Expert Comment

by:giltjr
ID: 26146317
If setting up port forwarding on your router worked, that means that one of your deivces was not connected to your internal network, it was coming from outside of your network, that is the Internet.  Hence the reason for my first question, was your phone using the Internet.
0
 

Author Comment

by:harsimar11
ID: 26146623
I agree.  And what I feel is that maybe the java app on symbian failed to use Wifi and started to use MedianNet.  

The fix:
From the java app, I started sending data to my phone ip and on router I opened the 8221 port.  I knew that this was going to work.  Then I setup port forwarding and I my app started receieving data from any device. :)

Before I was using the laptop ip on java app.

Well now it is fixed!
Thanks!
0

Featured Post

What Security Threats Are We Predicting for 2018?

Cryptocurrency, IoT botnets, MFA, and more! Hackers are already planning their next big attacks for 2018. Learn what you might face, and how to defend against it with our 2018 security predictions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Need WiFi? Often, there are perfectly good networks that don't have WiFi capability - and there's a need to add it.  - Perhaps you have an Ethernet port into a network but no WiFi nearby. - Perhaps you have a powerline extender and no WiFi at the…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question