I am having some problems with Sockets on Android. I have an app to which I am adding sockets, so the first thing I did was implement the sockets in a demo application. What it does is it loops through 255 IP addresses in the range 192.168.0.0 - 192.168.0.255 when it successfully connects the server writes data to the output stream and and the client reads the data and displays it to the user, this allows me to scan the wifi network for servers and list them to the user to allow the user to connect to one of them.
As soon as I run the exact same code within the existing application it starts doing strange things. The main issue at the moment is it is successfully connecting to every IP address in the loop.
Attached is a screenshot showing the incorrect behavior I am experiencing. I am expecting an exception being thrown when it tries to connect to an IP address with nothing to connect to.
The server in the example is running on IP 192.168.0.139 on port 6111 so I am expecting that all other IP's should throw the exception.
It does work as expected in my sample project I created to test this. So the first thing I did was make sure that the code is identical and then that all the gradle file config settings are the same, so I can confirm that they are using the same build tools and targetSdk version.
What else can I check to figure out why in the demo project it works but in the actual app it does not?
Related
I'm really scratching my head around this one.
I'm running a java server against a few test cases through a test tool and I'm getting a java socket timed out exception. The test tool runs on windows, while my server is deployed on a Raspbian. The test tool is black box so I do not know its implementation.
From what I gathered, the test case creates a client sending an http address to my server, say http://192.168.1.100:8080, in which my server is to make a connection and send data back to it. The port number is not static.
I verified that the port is opened by the system each test. I then placed Wireshark on the test tool's machine and found that the Syn packet made it to the machine, but Syn/Ack was never sent out.
I'm using java httpURLConnection, but I've also tried to make a java socket but both resulted in the same and throwing a socket timed out.
This problem does not come up if I run the server locally with with the test tool. What make this stranger is that it also happens to another code base, which is supposed to pass the test.
I don't know why it would not connect to the port.
More information: I'm working on an Onvif device controller. Onvif essentially provides a common interface between video streaming device and client applications. The server needs to conform to Onvif specs and passes the Onvif device test tool.
The problem above happens with test cases related to base event handlings, which follows WS-BaseNotification specs.The serer is given an endpoint so it can use to notify the client. However, given that that I'm getting a socket timed out, I don't think it is a schema parsing problem. The server throw an exception before any data was written to the output stream. The same problem happens with another code base which is supposed to be pass the test tool but the test tool also report that the notification was not delivered.
as you can read in title I'm making a super simple IOT (Not really)
and
using a esp8266 and want to make it connect to my home wifi network and make a communication between a android app and the module (android app connects to home wifi)
Note : Iam Using CODE VISION AVR
you may say :
Why not directly connect to ESP when its on Server Mode?
that's fine cause when ESP is server "he" can set ip for him self so
ip will be always same BUT I want it to connect to home wifi
-
Why you wont connect with IP ?
you cant find the module ip easily because its given by Wifi
-
Find ESP ip using IP scanner
Its not possible cause it changes every time and user have to change
IP every time in android app AND my app cant scann every time it want
to connect to a single device its so dumb...
-
Do a Static Ip for ESP !
well that's not possible too because maybe that IP was taken by
someone before ESP send static IP AT command ! + if IP wasent taken it may taken after Home Wifi Restarts !
Sorry for bad English :X
You can use software serial to configure esp8266 from arduino. You need to know the setup circuit perfectly. Keep it in mind that esp8266 operates on 3.3V where arduino gives 5V output. The most important thing is to send AT commands to esp8266. You can use the following command to connect with your wifi.
AT+CWJAP="Your_WiFi","password"
If you need to see the ip address of esp8266, you can use this command.
AT+CIFSR
If you want to set static ip to esp8266 , then you can try this one.
AT+CIPSTA="ip module","ip gateway","subnet mask"
Use mDNS responder:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server.ino
This way you would be able to connect to ESP8266 via hardcoded url like http://esp8266.local.
I'm designing a chat service that uses Java server sockets.
When a user connects to my server with their browser I need to make sure their connection information stays the same when they open new pages on my site in their browser. So I need to keep track of their remote IP address. I am using this below, but am unable to test it as I am on a local machine.
client.socket.getRemoteSocketAddress()
I want to test my system with multiple IP address from the client conenctions but I can not do so since this method above returns the same IP as I am local. How can I go about debugging and testing such a setup in Eclipse?
You could assign multiple addresses to a single NIC in Windows' Network properties->advance option.
Check out short tutorial:
http://www.tutorialspoint.com/shorttutorials/assign-multiple-ip-addresses-to-windows-8-computer
Also, you most like have to bind the address manually,
i.e. client.bind("some ip");
I'd like to know how a central server works in connecting two devices. I'm assuming that when the device application starts up, it should register its IP address and other pertinent information (username) with the server. When it wants to connect to another device, it should look to find the address of another device on the server, maybe with a get request. Then set up a to connect to a socket. If the device application closes, it should unregister from the server. Is this correct?
That's pretty much correct.
Because one or both devices are probably behind firewalls (including NAT), you have to assume they won't actually be able to connect directly to each other, so it won't be as simple as opening a socket to the other device once you find out its registered address. You will either have to try firewall-traversal techniques (which will usually be successful with UDP but not with TCP) or have a helper that isn't behind a firewall (which could be the same as the registration server or something else) carry all the data between the devices that wish to communicate.
Also, you will want to have the registration server time out registrations and the clients periodically refresh them, because clients won't always have a chance to deregister themselves on the server when they terminate or lose access to the network.
I'll like to combine both my initial problem which leads me to this one and this one.
my first problem was to be able to connect jaspersoft ireport 3.7.0 to MSSQL2005.I downloaded the jar from microsoft downloads and added the `jdbc4.jar` from the `irepot>tool>classpath>add jar`.
It went fine but i needed the port number other than 1433 since i'm using a named instance.so my first question is on which port to connect to a MSSQL2005 named instance?
During my search on google i found lot's of article like [this one][1] and [link text][2].i first did: `start>Microsoft SQL Server 2005>configuration tools>Sql Server Surface Area Configuration>Surface Area Configuration for service and connections` and allow remote connection.
I located listenALL at `Microsoft SQL Server 2005>configuration tools>Sql Server Surface Area Configuration>Sql Server configuration manager>protocol for instancename>TCPIP>protocol` which was yes
I Located IPALL at `Microsoft SQL Server 2005>configuration tools>Sql Server Surface Area Configuration>Sql Server configuration manager>protocol for instancename>TCPIP>IP addresses` and as in the second link i posted ,i removed `0` from TCP Dynamic Ports and assigne `90000` to TCP Port
I try to restart the database engine it keeps on saying: `the request failed or the service did not respond in a timely fashion. even though i undo every thing but still.Doesn't start from service manager.And it affected the SQLEXPress that got installed after i installed Visual Studio
i uninstalled the named instance but the SQLExpress is having the same behavior
Anyone to help me?this is critical thanks for reading this
Try to find free port with help of TCPview and then assign your DB Server to it.