Codesnippets > Network

Hier bitte weitermachen!!!

(1/1)

trucidare:
Hi,

hatte heute kurz vor feierabend ein wenig langeweile.
Kann das bitte jemand zuende machen?

mfg


--- Code: (glbasic) ---// --------------------------------- //
// Project: HTTP
// Start: Monday, January 26, 2009
// IDE Version: 6.143

AUTOPAUSE FALSE

GLOBAL clients%[]
GLOBAL ip%,rv%
GLOBAL Header$

GLOBAL www$ = "htdocs/"
GLOBAL index$ = "index.html"


init% = SOCK_INIT()
IF init% < 0
PRINT NETGETLASTERROR$(),0,0
SHOWSCREEN
KEYWAIT
END
ENDIF

Server_Sock% = SOCK_TCPLISTEN(8080)

WHILE TRUE
Client_Sock% = SOCK_TCPACCEPT(Server_Sock%,ip%)
IF Client_Sock THEN DIMPUSH clients%[],Client_Sock

FOREACH a IN clients%[]
rv% = SOCK_RECV(a,msg$,512)
IF rv%
Header$ = Header$+msg$
ENDIF
NEXT

IF Header$ <> ""
anzahl = SPLITSTR(Header$,parts$[],"\r\n")
IF anzahl
y = 0
FOREACH muh$ IN parts$[]
hup$ = MID$(muh$,0,3)
IF hup$ = "GET"
blah = SPLITSTR(muh$,wuerg$[]," ")
IF blah
file$ = MID$(muh$,LEN(hup$)+1,LEN(wuerg$[1]))
DEBUG file$
ENDIF
ENDIF
PRINT muh$,0,30+y*10
y = y+1
NEXT
ENDIF
ENDIF

SHOWSCREEN
WEND
--- End code ---

Navigation

[0] Message Index

Go to full version