# Is it possible to create a connection between Server-Client using ipv4 ip?

**URL:** <https://discourse.processing.org/t/is-it-possible-to-create-a-connection-between-server-client-using-ipv4-ip/12410>\
**Category:** Libraries\
**Created:** [June 30, 2019, 6:33pm UTC](https://discourse.processing.org/t/is-it-possible-to-create-a-connection-between-server-client-using-ipv4-ip/12410 "2019-06-30T18:33:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wirtex](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/wirtex/32/5701_2.png) [@Wirtex](https://discourse.processing.org/u/Wirtex)\
**Post date:** [June 30, 2019, 6:33pm UTC](https://discourse.processing.org/t/is-it-possible-to-create-a-connection-between-server-client-using-ipv4-ip/12410/1 "2019-06-30T18:33:50Z")

</div>

Hi guys, I made some online games thanks to [processing.net](http://processing.net) library but, I got a problem :  
the only way that I found to create a connection between Server-Client is using ipv6 but the problem is that I asked my operator for a static ipv6 but he couldn’t so the only static ip I can get is the ipv4 but [processing.net](http://processing.net) seems to not work with ipv4 (only with ipv6) so guys, can anyone tell me is there is a way to use processing net using ipv4?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 1, 2019, 1:01am UTC](https://discourse.processing.org/t/is-it-possible-to-create-a-connection-between-server-client-using-ipv4-ip/12410/2 "2019-07-01T01:01:34Z")

</div>

sorry, never play with this, but when i try  
/ Examples / Libraries / Network / SharedCanvasClient /  
& SharedCanvasServer  
from 2 computer in my LAN it works using

```auto
Client(this, "192.168.1.203",12345)

```

as server IP

 ![SNAG-0133](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/4d1f0b280d8b5cadf281b4b18af3a5e04d662f68.jpeg)

so why you not make a  
a minimal, complete and verifiable example ( **MCVE** )  
showing your problem.

---

<div class="post-metadata">

**Author:** ![Wirtex](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/wirtex/32/5701_2.png) [@Wirtex](https://discourse.processing.org/u/Wirtex)\
**Post date:** [July 1, 2019, 8:25am UTC](https://discourse.processing.org/t/is-it-possible-to-create-a-connection-between-server-client-using-ipv4-ip/12410/3 "2019-07-01T08:25:54Z")

</div>

Well, of course, here is the code for an simple sharing of 2positions of cubes :

Server :

```auto
import processing.net.*;

Server s; 
Client c;
String input;
int data[];

int x;
int y;

int oX;
int oY;

void setup() { 
  size(600, 400);
  background(204);
  stroke(0);
  
    s = new Server(this, 12345);
}

void draw() { 
  background(0);
  
  key();
  send();
  receive();
  
  fill(255);
  rect(x,y,30, 30);
  fill(100);
  rect(oX,oY,30, 30);
  
  
}

void send(){
  
   s.write(x + " " + y + "\n");
}

void receive(){
   c = s.available();
  if (c != null) {
    input = c.readString(); 
    input = input.substring(0, input.indexOf("\n"));
  data = int(split(input, ' '));
  
  oX = data[0];
  oY = data[1];
  
  }
}

void key(){
  if(keyPressed){
if(key == 'z'){
y -= 5;
}else if(key == 's'){
  y += 5;
}else if(key == 'd'){
  x += 5;
}else if(key == 'q'){
 x -= 5;
}
  }
}

```

and Client :

```auto
import processing.net.*; 

Client c; 
String input;
int data[]; 

int x;
int y;

int oX;
int oY;

void setup() { 
  size(600, 400);
  background(204);
  stroke(0);
  
    c = new Client(this, "2a01:e35:2f2a:520:95a3:d80c:e03a:d8ea", 12345);
}

void draw() { 
  background(0);
  
  key();
  send();
  receive();
  
  fill(255);
  rect(x,y,30, 30);
  fill(100);
  rect(oX,oY,30, 30);
  
  
}

void send(){
  
   c.write(x + " " + y + "\n");
}
void receive(){
 if (c.available() > 0) { 
    input = c.readString(); 
    input = input.substring(0,input.indexOf("\n")); // Only up to the newline
    data = int(split(input, ' '));
    oX = data[0];
  oY = data[1];
 }
}

void key(){
  if(keyPressed){
if(key == 'z'){
y -= 5;
}else if(key == 's'){
  y += 5;
}else if(key == 'd'){
  x += 5;
}else if(key == 'q'){
 x -= 5;
}
  }
}

```

And you can see that the connection only works (for me) using **ipv6** (but my **ipv6** is _dynamic_)

here is the result if you use **ipv4** :

 ![test1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e2ff04a0d89b45876aacb311f938f7200e50a0a4.png)

And here is the result when using **ipv6** :  
(I am a _new_ user so I can put only one image per post but, we can see on the image that when I use **ipv6** , there is an established connection between Server-Client) .  
So, if is oblivious that it doesn’t work for me with **ipv4** but why, and how to _‘prevent’_ it?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 1, 2019, 8:39am UTC](https://discourse.processing.org/t/is-it-possible-to-create-a-connection-between-server-client-using-ipv4-ip/12410/4 "2019-07-01T08:39:00Z")

</div>

-a- might be that the problem is your network/router/server setup,  
as IPv4 with processing or processing/net library works here,  
but sorry, IPv6 can not test, also not know if it even should work.

-b- and for play it should be ok to use dynamic IP,  
but SERVER thinking is for me connected with a static IP  
( set in server device ( or by router ))  
here i used a Raspberrry Pi with adding at end:  
`sudo nano /etc/dhcpcd.conf`

* * *

```auto
interface eth0
static ip_address=192.168.1.103/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 8.8.4.4

interface wlan0
static ip_address=192.168.1.203/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 8.8.4.4

```

as i use the RPI mostly from remote SSH / VNC

* * *

even i can not help you with your question, possibly it is now more clear for others.

---

<div class="post-metadata">

**Author:** ![Wirtex](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/wirtex/32/5701_2.png) [@Wirtex](https://discourse.processing.org/u/Wirtex)\
**Post date:** [July 1, 2019, 8:46am UTC](https://discourse.processing.org/t/is-it-possible-to-create-a-connection-between-server-client-using-ipv4-ip/12410/5 "2019-07-01T08:46:52Z")

</div>

Maybe you are right and the problem is elsewhere: I asked my internet operator (free) to give me a static ip and they did but, I noticed that my ip changes only the end (I explain myself) :  
Here is my ipv6 : 2a01:e35:2f2a:520:992a:177f:b2c4:\*\*\*\* (last carachters are covered in case ^^)  
and I noticed that when it changes, it still begins by 2a01: … so maybe the problem is coming from me cause I don’t really know a lot about network (i’m 14) but, yeah. so how could I could I cahnge the router settings?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 1, 2019, 9:05am UTC](https://discourse.processing.org/t/is-it-possible-to-create-a-connection-between-server-client-using-ipv4-ip/12410/6 "2019-07-01T09:05:00Z")

</div>

-a- from the picture i understand you use

- processing 3.4
- server and client code run on the same PC?? not a valid test?

-b- you state that it works

- with ipv6
- but not ipv4

so possibly “the” network not allow ipv4 communication??  
sorry, but without 2 devices in YOUR OWN network  
it might be very limited to play with that kind of things.

and if it is not YOUR router do not mess with it!

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 1, 2019, 12:46pm UTC](https://discourse.processing.org/t/is-it-possible-to-create-a-connection-between-server-client-using-ipv4-ip/12410/7 "2019-07-01T12:46:18Z")

</div>

> [@Wirtex](#):
>
> I asked my internet operator (free) to give me a static ip and…

Are both server & client sketches running on the same computer?  
Or are they on diff. computers but on the same LAN?

It is rare, but it’s possible that an ISP installs a simple modem in our home instead of a complete modem+router.

If it is the former, we need to buy a router in order to get LAN IPs.  
Otherwise, our only LAN IP would be the same as our WAN IP.
