TCP connection between Android App and PC - java

I'm trying to create a TCP connection between my PC and Android smartphone to send text from the PC (Client) to the Android App (Server).
I found a tutorial which helped me with the code for the App which creates the server ( http://pastebin.com/z0xPSAvP ).
Now I'm struggling connecting my client with the server. The client is programmed with "AutoIt"
http://pastebin.com/tCW5bK9V
When I run the client the "could not connect to $socket" msg-box is displayed.
Could someone tell me what I'm doing wrong here?
Both devices are in the same Network (smartphone via WiFi and PC via LAN) and I checked for the smartphones IP in the smartphone settings.

First, try to access something like Google from your Android phone using its mobile browser. Maybe something still wrong with the network.
Then create a version of the server that could deliver simple HTTP response, visible from the Android mobile browser. Doing so with success eliminates firewalls and all client-related issues from the list of possible problems, making sure the server works and is accessible.
If it still does not work after you demonstrate connection between server and mobile browser, I would suggest to write the client in Java first using the this tutorial. You can try AutoIt and other more exotic approaches after you get anything working at all.

Related

How to detect a c++ program on an unknow computer on the local network from an Android device

I have a program that is in C++ on a computer. I also have a Android app (Android version > 4.0). Both are communicating via TCP socket. The C++ program is the Server Socket, and the android app is the Client Socket.
Now, this works well if I tell my Android app what is the port and IP of the C++ server. I would like to be able to discover my C++ program from the Android device. After some research, I found that I could broadcast a message on the network from the C++ program that contains the IP and Port of the computer. Then my android program will listen to the broadcasting address until it listens to the server's broadcasting message.
I don't know how to do that in C++... Is is a good idea? If yes how can I do that? If not, what would be the better idea?
Thanks!
Getting client-server stuff working reliably can be quite challenging; there always seems to be one more edge-case that needs to be resolved. Rather than rebuilding the wheel, I recommend just using an existing library where someone else has already worked out all the kinks. I haven't used it yet, but the AllJoyn open-source project looks very promising.

Creating a Wifi peer to peer connection between Android and PC

I have a question about the p2p functionality of Android OS (4.x and higher). I have a PC program that makes use of the Boost C++ library that can function as a server or as a client. Now i have a Android app that has a server using Java sockets. This program need a accesspoint to connect to each other.
I'm looking for a way to connect the Android server and the PC client program without a accesspoint. After looking around i found out that Android has a p2p library.
Android P2P
As a read it you can only connect two Android devices with each other, my question is if it is possible to use this library to connect the Android device to the PC using wifi p2p? Or if there is a other possiblity? All suggestions are welcome!
Roy, have a look at this: http://en.wikipedia.org/wiki/Wi-Fi_Direct
WiFi P2P is now called WiFi Direct, and it is indeed possible to connect two devices as long as one of the devices supports it. So Android device in P2P mode and a PC without any special configuraiton should work fine. However, the PC can (probably) only connect to one access point at a time, from its perspective the Android device is the access point, it would have to disconnect from its usual access point to connect to the Android device.
Also check out SoftAP.

send sms from php using local phone-modem as sms-gateway

is there a way to send sms using local cellphone connected to pc,from php web applications ?
i understand that it can be done by external gatways but unforunatly my php project is offline based. so i was wondering if there is any way to do this wihtout need for internet connection.
i have googled a lot and found there is couple lib for java like serial-comm and smslib but is it possible using php ?
im using xampp on windows to host my web app on local network
Apache 2.4.3
MySQL 5.5.27
PHP 5.4.7
phpMyAdmin 3.5.2.2
FileZilla FTP Server 0.9.41
Tomcat 7.0.30 (with mod_proxy_ajp as connector)
Strawberry Perl 5.16.1.1 Portable
my project is based on php5-Codeigniter-doctrine orm-mysql-mysqlite
if it cannt be done using php, can i some how code a helper with other programming language (ror,java web,etc..) that would facilitate communication between connected sms gateway and web app with minimal messing with my network setup?
also can some one please explain the criteria of phone that can be used as an sms-gateway ?
Note: my clients sms traffic will not exceed 50 sms per day/per local-network/per modem ,
at most.
one of best resourse i found online about this topic is here http://www.developershome.com/sms/howToSendSMSFromPC.asp
you can send sms using php but you have to setup a sms gateway server. you can then post/get request to that url to send sms. now that sms gate way server should have a gsm modem or a mobile phone connected.
So requirements are
SMS Gateway with GMS Modem / Mobile Phone attached.
A url on the server upon whihc you can send request

Android chat working on emulators with redir

I have read tons of this same advices about connecting two emulators using telnet. For example this one: Connecting 2 Emulator instances In Android
I've made all as it is said and nothing works. I have got server app on emulator 5554 and client app on emulator 5556. They are using ports 6000 server app and 5000 client app. What I want is to communicate when this two emulators are open - in both ways.
At the beginning server app shows her ip, and in client app user have to write this ip. That is whole configuration.
As in mentioned post was said I've written redir add tcp:5000:6000 but nothing works. Also when I write redir add tcp:6000:5000 nothing happen. Those apps don't hear each other. However if server is on other device than everything works fine.
Maybe it is stupid question but can someone guide me through this, because I don't know what am I doing wrong.

wireless connection between mobile device and pc

I would like to establish a connection between a mobile device and computer so they can interact with each other. I should be able to send and receive data at both the ends, just like a chat client. How do I go about it? I just want to know the steps involved. I was thinking about sending the data from the device to a database server and then accessing it through the PC, and doing the same on the mobile device, too. Is this a good idea? What alternatives are there?
Since you're using android, this is pretty easy. One easy option is to code a client and server application for your android device and pc. Or, you could just send data on the UDP connectionless protocol.
I'm assuming you know how to build apps for an android phone. There is no need of an intermediate node (a database server or the like), if the goal here is as small as just sending data back and forth.
Here's a good example of a UDP server/client implementation.
And here's a good one for TCP server/client.
Hope that helps.

Categories