Networking Question

Just starting out? Need help? Post your questions and find answers here.
berklee
User
User
Posts: 36
Joined: Wed Jul 28, 2004 3:45 pm

Networking Question

Post by berklee »

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.
berklee
User
User
Posts: 36
Joined: Wed Jul 28, 2004 3:45 pm

Oh - also...

Post by berklee »

I'm also wondering - if I were to leave the server as single-threaded, would the network requests be queued?
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

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/
berklee
User
User
Posts: 36
Joined: Wed Jul 28, 2004 3:45 pm

strange

Post by berklee »

I've noticed in the last couple of releases that the network library hasn't had much work done to it.

Has it been abandoned?
berklee
User
User
Posts: 36
Joined: Wed Jul 28, 2004 3:45 pm

Post by berklee »

Sorry, just thought I'd bump this thread - I'm really curious to know.

Is the Networking Library something that we should not expect to be completed?
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

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 :)
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Hm, what is the problem of the network-lib? it has all you need to create a server/ client.
Tranquil
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Post by HeX0R »

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 :

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
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...
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Hm, many month ago I thought that Fred said, that the PB Network commands are nothing more then wrappers to the Windows API.
Very crrazy your problem.

Mike
Tranquil
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Yeah...

I miss some stuff on the Network library...

A bloody ping ...
PingClient(ip)

Some sort of DNS trace...
DNSTrace(ip) [this would be great for RBL spam checks]
berklee
User
User
Posts: 36
Joined: Wed Jul 28, 2004 3:45 pm

Post by berklee »

For me, it started because I wanted to create a server with the PB Networking library.

Although I can manage the sessions with multiple users, I wanted to be able to track IPs as well.
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

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
Post Reply