We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have created Android app as tcp client and my pc is acting as tcp server(processing in java mode).I am using oscP5 library.
When i try to run android app on mobile (with Wifi or mobile data 'on'), black screen will appear. After few minutes, app got loaded with error (TcpClient IOException while trying to create a new socket processing).
But when i load the android app without internet connection, it works normally. But, of course, it's of no use.
Also, when i run both client and server in Java mode, everything works fine.
I have tried these things:
Kindly help.
TCP Server
import controlP5.*;
import oscP5.*;
import netP5.*;
ControlP5 cp5;
OscP5 oscP5tcpServer;
OscMessage theOscMessage;
String s = "";
void setup() {
size(360, 360);
background(164);
oscP5tcpServer = new OscP5(this, 12345, OscP5.TCP);
PFont font = createFont("arial", 20);
cp5 = new ControlP5(this);
cp5.addTextfield("output")
.setPosition(20, 100)
.setSize(200, 40)
.setFont(font)
.setFocus(true)
.setColor(color(255, 0, 0));
textFont(font);}
void oscEvent (OscMessage theOscMessage) {
String thirdValue = theOscMessage.get(0).stringValue();
s = thirdValue ;
if (theOscMessage.checkAddrPattern("/test")==true) {
println(thirdValue);}}
void draw() {
cp5.get(Textfield.class, "output").setText(s);}
TCP client
import oscP5.*;
import netP5.*;
import controlP5.*;
ControlP5 cp5;
OscMessage myMessage;
OscP5 oscP5tcpClient;
void setup() {
size(360, 360);
cp5 = new ControlP5(this);
oscP5tcpClient = new OscP5( this, "141.44.219.124", 12345, OscP5.TCP);
cp5.addButton("colorA")
.setPosition(100, 100)
.setSize(150, 39);
cp5.addButton("colorB")
.setPosition(100, 140)
.setSize(150, 39);}
void draw() {
background(0);}
public void colorA() {
OscMessage myMessage = new OscMessage("/test");
myMessage.add("Gavanpreet Singh"); /* add a string to the osc message */
oscP5tcpClient.send(myMessage);}
public void colorB() {
OscMessage myMessage = new OscMessage("/test");
myMessage.add("InDP Project"); /* add a string to the osc message */
oscP5tcpClient.send(myMessage);}
Answers
Try using a local WiFi network. It seems you are trying to connect through the network of the service provider of your phone. Is that correct?
Kf
Yes, I am using my university network actually, which is service provider network, of course. Are you telling that i have to use private ip instead of public ip?
It is working. voo hoo... :)) @kfrajer: Thank you so much.