Networking Question
Networking Question
Is there a way to identify someone's IP address using the PB network library? I'm working on a server and would like to incorporate that information into some session management.
Oh - also...
I'm also wondering - if I were to leave the server as single-threaded, would the network requests be queued?
The network library for PB is currently unfinished. It's one of the libraries in PB that have not been finished. So, your best bet is to use a third party network library, especially if you want to do ANY kind of server programming..
A good one can be found @ http://www.gnetlibrary.org/
A good one can be found @ http://www.gnetlibrary.org/
Not to be negative here, but Im trying to remember what was happening in my last post. I believe there was missing disconnect state. And cannot send strings w/o a delay of one millisecond coded in after or before the send. Or the string doesnt send.
Anyways, I think the client side is almost there
The server side leaves a bit to be desired. However, hopefully it'll be complete around PB 4.0 
Anyways, I think the client side is almost there


The network-lib is terrible buggy!
I had lots of problems with it a while ago...
The following code wasn't running on a Win98SE Machine, runs with an inacceptable lag of 10 or 12 seconds on another Win98 Machine and runs like hell on a winXP PC :
After getting nothing but nonsense answers (in the german board) i decided to use the Winsock-Api, which runs just smooth on any win-version...
I had lots of problems with it a while ago...
The following code wasn't running on a Win98SE Machine, runs with an inacceptable lag of 10 or 12 seconds on another Win98 Machine and runs like hell on a winXP PC :
Code: Select all
#Port = 1024
If InitNetwork()
If CreateNetworkServer(#Port)
netid = OpenNetworkConnection("127.0.0.1", #Port)
If netid
MessageRequester("Info", "O.K.", 0)
CloseNetworkConnection(netid)
End
EndIf
MessageRequester("Info", "Error", 0)
End
EndIf
MessageRequester("Info", "No Server", 0)
Else
MessageRequester("Info", "No Network", 0)
EndIf
{Home}.:|:.{Dialog Design0R}.:|:.{Codes}.:|:.{History Viewer Online}.:|:.{Send a Beer}
-
- Addict
- Posts: 2344
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Code: Select all
InitNetwork()
Procedure.s GetIP(Host$, File$, _Data$)
File$ = "/ip.php"
ConnectionID = OpenNetworkConnection("bradan.i-networx.de", 80)
If ConnectionID
String$ = ""
String$ + "GET " + File$ + " HTTP/1.1" + Chr(13) + Chr(10)
String$ + "Host: " + Host$ + Chr(13) + Chr(10)
String$ + "Content-Type: application/x-www-form-urlencoded" + Chr(13) + Chr(10)
String$ + "Connection: close" + Chr(13) + Chr(10)
String$ + Chr(13) + Chr(10)
SendNetworkString(ConnectionID, String$)
While NetworkClientEvent(ConnectionID) <> 2
Delay(1)
Wend
*Buffer = AllocateMemory(50000)
ReceiveNetworkData(ConnectionID, *Buffer, 50000)
Text.s = PeekS(*Buffer)
FreeMemory(*Buffer)
Text = ReplaceString(Text, Chr(13), Chr(10))
Start = FindString(Text, Chr(10)+Chr(10)+Chr(10)+Chr(10), 1)+8
CloseNetworkConnection(ConnectionID)
Text = Mid(Text, Start+1, (Len(Text)-Start))
Text = Left(Text, FindString(Text, Chr(10), 1)-1)
ProcedureReturn Text
EndIf
EndProcedure
Debug GetIP("bradan.i-networx.de", "/ip.php", "")
bye,
Daniel
Daniel