How obtain IP adress of other Pc in ubuntu 14.04 or later?

Hello I am beginner programmer and i make my final thesis of Magister in electronic art.
My project its a multi-player on line video game . For thats i Need know by software the IP adress of logged computer to server .
I haven’t a server today but I have two Pc in my house and I like make a prototype code for intra-net.
Actually I have two C++ code Hi interchange data in UDP protocol. For that I put by hand the Ip adress but I need make that by software.

Any person have a simple code for that ???

Thank full

( if you can write in spanish better ).

apple developed a protocol to discover services on a local network called “bonjour”.
many others followed suite, it’s also often referred to as zeroconf networking. avahi is an open implementation that i think works on all platforms and not just ios/osx.

arturo has put together a little openframeworks addon. it’s outdated, but should be a good starting point.

you could also try just using the computer names (ie connect to “mycomputername.local”). i use that a lot, but maybe thats a mac os thing. not sure.

btw, all that will only work on a local network only. if you are going to use this over the internet at some point you’ll need to have a fixed ip for the server and then get the ip addresses of the clients when they sent the first package

THank full for your reply.
Yes I think make a intranet with a fixed Ip server in the near future. but I like make a protoipe experiment in mi two Pc and later if that run good In a Ip fixed server.

Them, the addons ofxAvahiCore and AvahiClient serve to obtain the IP of my PC plug in the same Modem ???


yes, you only need ofxAvahiClient, ofxAvahiCore is used for systems where there’s no avahi server

Catastrofic . I compiled your example: i open code proyect generator, i put a sketch name, i select ofxAvahiCore, ofxAvahiClient and ofxNetWork run compilation::::::::::: error in main.cpp line 11 expected type-specifier before ‘ofApp’

Its the first time that this error happenes in more 100 codex. Very rare because i only change the width and heigth window to 600 * 600 . Always i make that an never occur this error.

Mi Got I not know cry or laugh, jajajajaj

I copy paste your code in a code block proyect…

Thank full for your help Arturo

greetings to Argentina

I solved parcially the problem with a ofxMyIp library:
The code offer a function getList(), hi return all Ip and masc addres of local PC in string type.

well now I need a server (the future is now, jajaj ) The idea its that’s: I know the IP server, them in my code one pc that connects at this server send your IP detected by ofxMyIP::getList(); So other computer connects at the same server and send your IP by similar way, them when the server send data to all Pc hi have registerded all IP logged IN.

Its important have control of logged and un logged Pc for incomming and out comming message.

THank full
special thank full to kritzikratzi and arturo for help my.