Page 1 of 1

DHCP Server ?

Posted: Thu Mar 16, 2006 9:53 am
by Progi1984
Do you think that it's possible to code a DHCP server in PureBasic ?

Re: DHCP Server ?

Posted: Thu Mar 16, 2006 10:04 am
by Michael Vogel
Progi1984 wrote:Do you think that it's possible to code a DHCP server in PureBasic ?
Think so, but I think it will not be easy to do that platform independent - so in what OS should it run?

All I did is to send and receive ICMP packets to do a network scan with windows - this can be done by API calls, but as I know, "self defined packets" can't be done (easily) with standard winsock. Maybe someone else has already read the available documentation of winsock?!

Posted: Thu Mar 16, 2006 10:06 am
by Progi1984
Is it not possible to do that with purebasic commands ?

Posted: Thu Mar 16, 2006 10:50 am
by Michael Vogel
Progi1984 wrote:Is it not possible to do that with purebasic commands ?
No, just have a look into the Network Commands of PureBasic - more than in other languages, but still only for simple things (get own ip addresses, etc.) and special commands for doing a client server relation between two PureBasic programs (network games, etc.).

If doing advanced things, it can still be a possibility which is not too complicate, if you know how to do the API calls or the call for a certain DLL. For instance, the following lines are still PureBasic commands, if you want - but they call the windows API for doing a "ping"...

Code: Select all

	ResultSize = SizeOf(ICMP_ECHO_REPLY)+Len(Packet); anstelle von Len(Message)
	*Result = AllocateMemory(ResultSize)
	*Echo.ICMP_ECHO_REPLY = *Result

	If IpAddress <> 0
		hFile = IcmpCreateFile_()
		If IcmpSendEcho_(hFile, IpAddress, Packet, Len(Packet), 0, *Result, ResultSize, Timeout) > 0
			Ergebnis=*Echo\RoundTripTime
		Else
			Ergebnis=-1
		EndIf
		IcmpCloseHandle_(hFile)
	Else
		Ergebnis=-2
	EndIf

	FreeMemory(*Result)

Posted: Thu Mar 16, 2006 5:26 pm
by Shannara
Vogel is right on the dot. The server side aspect of PB is great for simple things, but its not complete.

Posted: Thu Mar 16, 2006 7:23 pm
by Nik
I don't consider ICMP packtes something which is really needed for normal software, but you are right there are problems in the network lib nevertheless, we even have examples that show that you can write an ICQ Client in Purebasic which indeed is advanced. A DHCP Server though needs API since it needs IMHO commands which are very raely usefull in normal applications even in Network ones.