It is currently Sun Jul 12, 2020 12:55 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject:
PostPosted: Mon Oct 15, 2001 3:28 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by tranquil.

Howdy ho!

At first a hello to all Pure Users. I'm a newbie and want to code my first application.
This should be a File-Sharing tool like Napster but optimized for LAN Partys.

And here are my short Problems:

1.)
I need to find out the Local IP(s)where the client/server is running.
Is there a source code available or a System-Command?

2.)
Bug or not!? Hm, If I use the "StatusBarText" Command in combination with the Network Library my Server Recieves Crap Messages from the clients. (Sometime it works, other times the server recieve the same text that I put in the Statusbar)

Thanks for any help!

Mike

Tranquilizer/ Secretly!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 15, 2001 11:36 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Franco.

Willkommen Michael!
Tryed to help but I don't get the right result.(I'm not a prof coder)

The commands that you have to use are:

WSAStartup_() needs 2 parameters -> initializes the wsock stuff
GetHostName_() needs 2 parameters -> get the Hostname
GetHostByName_() 1 parameter -> get the HostIP# from the Hostname
WSACleanUp_() -> this has to be!

I get the right result from GetHostName_() but after that, you have to use
GetHostByName_() and the return of it is a pointer to a pointer to....
And I really don't get it, sorry.

But if you don't get lost in pointers (like me ) probably this could be a help,
now that you know where to start.



Have a nice day...
Franco


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 16, 2001 12:02 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by fred.

Quote:
The commands that you have to use are:

WSAStartup_() needs 2 parameters -> initializes the wsock stuff
WSACleanUp_() -> this has to be!



Don't call these commands anymore ! There are called in InitNetwork and when a program ends..


Fred - AlphaSND


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 16, 2001 10:36 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by tranquil.

Okay, I will check the "pointer 2 pointer" version today. :)
The Problem is that a maschine can have more then one IP at the same time, URGS,
but thanks a lot, possible u helped me a little bit.

Mike (and my name is not Michael! *smile*)


Tranquilizer/ Secretly!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 18, 2001 11:51 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Ants.

Quote:

GetHostName_() needs 2 parameters -> get the Hostname
GetHostByName_() 1 parameter -> get the HostIP# from the Hostname


These commands, as far as I know, are for getting the the IP of your machine, or the ASCII name of a known IP address. To get the IP of another machine, you have to do it manually, ie: tell people what it is, or run a Domain Name Server on your LAN, then create an entry for your Server as an ASCII name - like `FileServer'.
Either that or use Windows filesharing functions- ie: to look up what machines are in your Network Neighbourhood.

Cyas- Ants

Anton Reinauer


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Oct 19, 2001 12:43 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by tranquil.

I need the IP of the local machine, not of another one.
But to get it it seems to be very hard.

does anyone have a source for this??

Tranquilizer/ Secretly!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Oct 20, 2001 2:26 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by MrVainSCL.

Hi tranquil - my little silly cousin :wink: - here is the solution how to find your local ips!It was much as easier as coding a "hello world" in pb :wink:) Have fun...

;---------------------------
; GET IP Example
;
;NetWork References...
;
;http://www.vbip.com/winsock-api/gethostname/gethostname-01.asp -> How To get name And IP address of the local system
;http://www.vbapi.com/ref/h/hostent.html -> HOSTENT Structure
;
;If you need all IPs of your system, its much as easy, please call us if you have problems.
;
;Tranquilizer & Mr.Vain of Secretly!
;---------------------------


a=initnetwork()
*buffer = GlobalAlloc_(#GMEM_FIXED | #GMEM_ZEROINIT, 2048)

Procedure.l calc(va.b)
If va.b<=0
res.l=256+va.b
Else
res.l=va.b
EndIf
ProcedureReturn res.l
EndProcedure


a=gethostname_(*buffer,2048)

adr.l=gethostbyname_(*buffer)

h_name.l=peekl(adr.l) ;Point to host name
h_array.l=peekl(adr.l+4) ; Pointer to an Array -- NOT REQUIRED YET
h_addrtype=peekl(adr.l+8) ; Addr type Integer -- NOT REQUIRED YET
h_length=peekl(adr.l+12) ;Length as integer -- NOT REQUIRED YET
h_addr_list=peekl(adr.l+16) ; List of Addresses (IPs)

ipadr.l=h_addr_list

ipb1.b=peekb(ipadr.l)
ip1.l=calc(ipb1.b)

ipb2.b=peekb(ipadr.l+1)
ip2.l=calc(ipb2.b)

ipb3.b=peekb(ipadr.l+2)
ip3.l=calc(ipb3.b)

ipb4.b=peekb(ipadr.l+3)
ip4.l=calc(ipb4.b)

messagerequester("Host:"+peeks(h_name.l),"Your first IP:"+str(ip1.l)+"."+str(ip2.l)+"."+str(ip3.l)+"."+str(ip4.l),0)

End


MrVainSCL!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye