What connection settings needs to be used in order to connect chat client to server? - vb.net

So I am playing around in Visual Basic and I'm making a chat client and server. I already did both and tested it on local machine and works. Server listens to connection and records all activities. This is reflected in chat client.
Here's the line of code that I use in order to connect to the "chat server" on same computer.
Dim clientSocket As New System.Net.Sockets.TcpClient()
clientSocket.Connect("127.0.0.1", 8888)
Anyone know what kind of settings I would need in order to connect remotely to another computer that has the chat server running?

The short answer is that you need to change the IP. But the real question is how do you get the IP?
Now if this is just for fun or something, you could just PING the computer if you know the name or walk over to that computer and run something like IPCONFIG on it.
But, in the real world, with a real chat, when a client launches, you would then grab the IP programmatically and post it along with some other info, like the User Name, to a database or web service (which you also created) so other clients would know it is online. You would also need to remove that record or update it with an offline flag or something as well as handle cases where the client looses network connectivity or ends unexpectedly. You can see where I am going with this...
The point is, this needs to be the IP of the client you want to talk to. 127.0.0.1 always refers to the local computer or device.

Related

Reprogramming Pet GPS tracker to send data to my own server

sorry if this is the wrong "stack". I could not find a better suited.
I bought a GPS tracker for my dog, which came with a subscription, a SIM card and a poorly developed app.
I have cancelled my subscription and want to use the device to send location info to my own server.
The device has a micro USB input and a SIM card slot. There is not much more I know, but if you have questions which may help find the answer, I can try to take it apart a little more.
So basically, is there some way I can reprogram this device to use my own SIM-card and app?
Plugging the device into my computer does nothing(as expected) however it does register in devmgmt.
Do not worry about the actual reprogramming, I can handle that myself.
Thanks in advance
Edit:
Thank you for feedback.
Image provided.
It does not, as I first thaught, register in the device manager.
I do have an IMEI number for it, but I cannot see a manufacturer anywhere on it. It might be on the underside, but the battery is glued on there.
Based on the Model Number LK120 After some Googling I found a documentation with the following SMS commands. Link to documentation LK209
Note send the commands without Square Brackets
// I guess you've already done 1 and 2.
1 - Set Admin Number - admin123456 [YOUR_PHONE_NUMBER]
2 - Set APN - apn123456 [APN_DETAILS]
//123456 seems to be the password - If the company you got the tracker from provided a different password - try that.
3 - SET the IP and Port Number - adminip123456 [IP_ADDRESS] [PORT_NUMBER]
As this Tracker is either TCP or UDP based - Can't really tell without the actual protocols and User Manual - you will have to setup a TCP and UDP Server and see which Protocol the Tracking Device connects via.
There are a few free software that can setup a TCP/UDP Server on your local machine for testing. [https://packetsender.com/]
Note that the IP address you set on the Tracker must be your Public IP Address, not Local LAN IP Address. You can get the Public IP from here - https://www.whatismyip.com/
Also you will need to open the port of your choosing on your Router and forward the Port to your PC make sure the port is not in use by another application e.g. 9999. This is possible for most Routers. You should be able to access your router admin panel using a browser, details should be on your router.
Also open the port on your PC firewall.
You can always check if it is possible to connect to your Server by going to CMD and running the following command (or use the Packet Sender software to test)
telnet [PUBLIC_IP_ADDRESS] [PORT]
If you can connect via the above command then the tracker should also be able connect.
Note Let us know if the SMS commands work, you should get a response if they work.

PeerConnection based on local IP's

What I want is, basically, to create a connection between two different computers on same local network. But i want to do this by computers' local IP's. (like 192.168.2.23 etc)
This must be a totally local connection. no TURN or STUN Servers. I am not sure if this is possible. Because there are not much documentation/example/information about WebRTC.
So, how can I create a connection from my computer to another one just passing its local IP as parameter?
Update: To be more clear; imagine there is an html page contains some code that activates my camera and audio services. and another -almost same- page is open in other computer. Waiting a connection request... And there is a textbox in my page to type an IP belongs to other computer on my local network. type 192.168.2.xx and bingo! i have connection between me and other computer.
I want this process as IP based, because there may be more than 2 devices on the network. And all of them are possible devices to create connection. So i need to reach them by their IP's.
Any example code or explanation would be great! even if it tells that this is not possible.
Thanks
Peer discovery is a vital part in any WebRTC application. It's an expensive term for saying: "Hi, I'm computer 4 and I want to talk to you!".
See it as calling a friend over the phone. You need to dial his number first.
This part is not defined in the WebRTC standards. You need to implement this logic in your application. Once you know who you want to call, you need a way of exchanging vital information. This is called signaling, like flo850 put in his answer.
Signaling is needed before any peer-to-peer connection can be set up.
To come up with an idea for your use case of 7 devices in a LAN.
If you have these devices connected to for example a WebSockets server and are in the same channel.
The WebSockets server can be written to route messages to specific receivers.
Devices connected to the channel often are identified with some kind of ID, imagine you use the device's IP.
When you want to talk to computer 4 with IP 192.168.0.4 you send the exchange messages (signaling) on the channel to the receiver with ID, the IP of the device you want to connect with.
How to send the signaling (offer, answer) is described here with example code.
Hope this helps
Users usually sit behind NATs; that's why ICE concept implemented in WebRTC.
If both users are sitting behind same NAT; you can skip ICE servers by passing "NULL" parameter value over "RTCPeerConnection" constructor:
var peer = new [webkit|moz]RTCPeerConnection ( null );
Now, browser will use "host" candidates, also known as "local" candidates.
you still need a signaling server. During the ICE candidate search, your clients will exchange their local ip through this signaling server

Able to RDP into remote server, but not able to ping or telnet

We have a Win Server 2008 box being hosted (dedicated) for us.
I need to connect to one of it's DB's from a server in our LAN.
What started out as a "sure, I'll just throw that together for you real quick" project has turned into a week-long hair-pulling pile of WTF :)
I am able to RDP into that server without fail or issue.
When I tried to connect to the DB, I got a generic "could not connect" error, so I went hunting.
Telnet attemtps and pings time out.
Since then, we have tried endless variations of firewall settings (including wide open), and still ... no go.
In addition to our firewall, the hosting provider also has a firewall layer.
We turned on all logging, and we don't even see any connection attempts at our FW.
We then had the hosting provider turn on all logging, and they don't see any connection attempts either!
Hrmmmph
I'm at a complete loss.
Any suggestions?
BTW, while I'm comfortable enough with all this to explore and make changes, my experience with firewalls and stuff is fairly limited, so don't hesitate to dumb it down ;)
It is hard to give just one answer to this question, because the interim results of the problem analysis lead to different steps that you need to do next. It will more likely be a step by step help with tracing down the problem.
Do not trust any firewall setting (esp. not any that someone else did, and again esp. not if you don't know him), unless you tested it. Firewall settings are tricky and even experienced professionals get them wrong now and then.
In the guide below, I will write <win2008server> in commands where you have to put the name or IP of the windows 2008 server to which you want to connect. On the other side, I will use the expression "office PC" when I mean your workstation PC in the office from where you are trying to connect to the win2008server.
STEP 1: Checking the Endpoints
1.) Can you telnet to the RDP port?
On your office PC, try this on a command prompt:
telnet <win2008server> 3389
This is to make sure that DNS name resulution works for telnet, as well as network hardware and routing. It should, because you can use RDP to establish this connection. However, anything can get in between, like the telnet command being in any way configured nonstandard or being replaced for whatever reason on a company pc (sysadmins have strange ideas at times...).
2.) Can you telnet locally on the win2008server to the database?
When logged in using RDP on the win2008server, open a command prompt on the server and issue the command
telnet <win2008server> <database port>
That means you are trying to connect from the server to itself. This is to make sure the database port is open on the server.
STEP 2: Checking the Firewalls of the Endpoints
If for 1.) and 2.), your answer is yes it works, you have to test if either the remote side can not be reached or your location can not connect to the internet on the port you are testing (database port). You do this by replacing the respective other side with any other host on the internet for which you know it's reachable or can reach other servers. Typically, you google for a port checker ;)
3.) Check if the win2008server can be reached from another location than yours:
3.1.) Check if the RDP port of the win2008server can be reached from a third party location:
Google for port checker and take the first result (e.g. http://www.yougetsignal.com/tools/open-ports/ ). Type in the name or IP address of the win2008server and the RDP port, usually 3389 . Click on "check" and wait for the success or the timeout.
3.2.) Check if the database port of the win2008server can be reached from a third party location:
Do the same as in 3.1.), just with the database port instead of the RDP port.
4.) Check if you can connect to an outside server on the database port:
For this to work, you need to know a server or create one, which is somewhere outside on the internet, and which listens on the database port. You typically do this by keeping your private PC at home run and accessible through RDP or SSH, and there you open a server and configure your private internet router to forward the connection correctly.
Another way to do this test is webspace with SSH access. Many webspace providers nowadays allow for an SSH login (usually any webspace at $4/month and above).
Let's assume you have SSH access to any such third party place. You can use nc (netcat) there to open a server socket on the database port with this command:
nc -l <database port>
If it's your private PC at home, you usually have to also configure your private router and set up a dynamic DNS name for your internet access for the whole story to work out. You do not have this extra work with a webspace based SSH login. However, there you can not test ports below 1024 because you do not have the privileges. Good luck with this ;)
After you got this, try connecting to the port that you opened:
4.1.) From your office PC with
telnet <third party location> <database port>
4.2.) If 4.1.) does not work, also try with the port checker, because you might have gotten something wrong with setting up the server. Look at 3.) for this, and use the <third party location> and <database port> with the port checker (fourth party check).
STEP 3: Blaming ;)
At least one of the things should have failed by now and you can start calling people and letting them know about your tests and the results. You should be able to combine the results logically, but never start with that. Think about how to convey the information. Start out with your findings and then let them have a moment for their own conclusion. It can be difficult to tell someone in another company or department that their firewall isn't configured correctly. They might deny this even in the presence of proof. Be patient. Explain your findings again. Hint at the conclusion. This can be the trickiest part of the whole problem solution.
I have to say that today I had the same problem.
My solution was just to edit secpol.msc and disable all the FW profiles; then, run services.msc and also disable Windows Firewall service.
After this server was pingable for me.

How can a server know which client is connecting it while the client is using getInputStream:outputStream:?

I am using hotspot to communicate with iPhone, I publish netservice and connect each other. While every client can find many devices, when one of them connect my device by using getInputStream:outputStream:, how can I know which one is connecting me? PS:I have tried to resolve IP, but IP address can change any time.
Make your hotspot send some defined credentials (such as a host name) on the first attempt to connect. When accepting an input stream, check, if these data are provided and you're all set.

Cocoa server with user friendly automatic port forwarding or external ip lookup

I am coding a mac app, which will be a server that serve files to each user's mobile device.
The issues with this of course are getting the actual ip/port of the server host, as it will usually be inside of a home network. If the ip/port changes, its no big as i plan to send that info to a middle-man-server first, and have my mobile app get the info from there.
I have tried upnp with https://code.google.com/p/tcmportmapper/ but even though I know my router supports upnp, the library does not work as intended.
I even tried running a TURN server on my amazon ec2 instance, but i had a very hard time figuring how what message to communicate with it to get the info i need.
I've been since last night experimenting with google's libjingle, but am having a hard time even getting the provided ios example to run.
Any advice on getting this seemingly difficult task accomplished?
The port of your app will not change. The IP change could be handled by posting your servers IP to a web service every hour or whatever time period you want.
Server should run a URL http://your-web-service.com/serverip.php?ip=your-updated-ip and then have your serverip.php handle the rest (put it into a mySQL db or something)
When your client start it should ask your site for the IP and then connect to your server with that.
This is a pretty common way of handling this type of things.