get ip address
-
- New User
- Posts: 6
- Joined: Sun Feb 20, 2005 10:35 pm
get ip address
I tried to write a simple platform independent server. It should run on linux as well on windows.
But there is one function really missing in the network library.
getclientip(client)
It should return the IP-address of the specific client. That would be great. Then I don't have to do my server in Java :-/
But there is one function really missing in the network library.
getclientip(client)
It should return the IP-address of the specific client. That would be great. Then I don't have to do my server in Java :-/
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
the only way around is i guess go native winsock ie. berkely socket io
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
linux should have socket support as well! but don't ask me how to do it 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
-
- Enthusiast
- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
Until it's added, or someone create a little userlib.
This one work with windows & linux:
Use it like this:
This one work with windows & linux:
Code: Select all
Procedure.s GetClientIP(ClientID)
Structure IPType
Reserved.w
Port.w
StructureUnion
IPLong.l
IP.b[4]
EndStructureUnion
Zeros.l[2]
EndStructure
s = SizeOf(IPType)
res = getpeername_(ClientID, @IP.IPType, @s)
If res = 0
remotip$ = StrU(IP\IP[0], #Byte)+"."+StrU(IP\IP[1],#Byte)+"."+StrU(IP\IP[2], #Byte)+"."+StrU(IP\IP[3], #Byte)
Else
remotip$ = ""
EndIf
ProcedureReturn remotip$
EndProcedure
Code: Select all
If InitNetwork()
If CreateNetworkServer(8181) = 0
MessageRequester("Error", "Can't Create Server", 0)
End
EndIf
Repeat
event = NetworkServerEvent()
If event = 1 ; Someone connected
Debug GetClientIP(NetworkClientID()); Here you go
EndIf
ForEver
EndIf
-
- Enthusiast
- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
And then Fred came and saved the day..
Just as I had the libs ready..
So if someone want's them until Fred adds it..
Windows->getclientip.zip
Linux->getclientip.tar.gz
Just copy into purelibraries(linux)/userlibraries(windows)
Works like the Procedure I posted earlier:
The source is there, but it ain't pretty..
Just a quick hack..
Oh.. And don't forget to remove the lib when Fred add the same command..

Just as I had the libs ready..
So if someone want's them until Fred adds it..
Windows->getclientip.zip
Linux->getclientip.tar.gz
Just copy into purelibraries(linux)/userlibraries(windows)
Works like the Procedure I posted earlier:
Code: Select all
ip$=GetClientIP(ClienID)
Just a quick hack..
Oh.. And don't forget to remove the lib when Fred add the same command..
Last edited by olejr on Mon Mar 07, 2005 7:39 pm, edited 1 time in total.
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
At the same time can you add client event #4???
-Anthony
-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system