|
Post by Darkjester on May 24, 2009 15:45:20 GMT -5
i remember seeing a basic4gl program that retrieves the ip where?
|
|
|
Post by crazynate on May 24, 2009 16:54:33 GMT -5
I cant remember but im looking for it
|
|
|
Post by crazynate on May 24, 2009 17:25:10 GMT -5
i couldn't find the demo so i made one ;D
dim connection(1) dim server server = NewServer (80000) connection(0) = NewConnection("localhost", 80000) while not ConnectionPending(server) Sleep(100) wend connection(1) = AcceptConnection(server) print ConnectionAddress(connection(1)) DeleteConnection (connection(1)) DeleteServer (server) end
|
|
|
Post by Darkjester on May 24, 2009 19:08:01 GMT -5
yay! lol
|
|
|
Post by crazynate on May 24, 2009 19:41:32 GMT -5
This also works ;D
dim connection connection = NewConnection("localhost", 80000) print ConnectionAddress(connection) DeleteConnection (connection) end
|
|
|
Post by Darkjester on May 24, 2009 20:11:01 GMT -5
how do i get my actual net ip, i know what it is but what if i wanted the program to get it, the ip it returns on those programs is just the loopback IP
|
|
|
Post by crazynate on May 24, 2009 20:18:17 GMT -5
i dont know what you mean by net ip and loopback ip i couldn't find anything about it in the network engine guide
|
|
|
Post by DJLinux on May 25, 2009 4:34:22 GMT -5
"GetMyWanIP" is a part of the Socket Plug-In if you take look on this example you can see it's a http get request to: www.whatismyip.com/automation/n09230945.aspJoshy ' TCPGetMyWanIP.gb TCP high level API ' get your curent WAN IP ' ' remove HTML header from string function CutHeaderFromText$(Text as string) dim i as integer for i=1 to Len(Text)-4 if Mid$(Text,i,4)=HEADER_END then return Right$(Text,Len(Text)-(i+3)) end if next end function ' const SERVER$ = "www.whatismyip.com" const PATH$ = "/automation/" const FILE$ = "n09230945.asp" const PORT = 80 ' web server port ' dim hSocket as integer dim msg as string ' hSocket=TCPSocket() if hSocket<=0 then printr "error: can't create TCP socket !" end if ' if TCPConnect(hSocket,GetIpFromHost(SERVER$),PORT)<0 then printr "error: can't connect to " + SERVER$ + " !" CloseSocket(hSocket) input$():end end if ' ' build and send HTTP GET request msg= "GET " + PATH$ + FILE$ + " HTTP/1.1"+ LINE_END msg=msg+"Host: " + SERVER$ + LINE_END msg=msg+"Accept: text/html;text/plain" + HEADER_END ' if TCPSendString(hSocket,msg)<=0 then printr "error: SendString !" else if TCPReceiveString(hSocket,msg) then printr "your curent internet IP are:" printr "----------------------------" msg=CutHeaderFromText$(msg) printr msg else printr "got no answer!" end if end if CloseSocket(hSocket) ' While True Sleep(100) Wend end
|
|
|
Post by Darkjester on May 25, 2009 20:36:24 GMT -5
Thnx djlinux, is this posible in your new plugin? i dont understand networking very well yet im working on it though ;D
|
|
zack8686
Posts a bit
gl-Home in wikispace
Posts: 207
|
Post by zack8686 on May 26, 2009 8:25:41 GMT -5
How to download file(e.g. : zip file , executable , mp3 , video ...) using Socket Plugin ?
|
|
|
Post by DJLinux on May 26, 2009 18:51:38 GMT -5
How to download file(e.g. : zip file , executable , mp3 , video ...) using Socket Plugin ? there are examples in the plug-in download GetPicture.gb GetSound.gb ... the rest is your turn the way is all same you have to build an HTTP request for text, jpg, png, gif, zip, wav, mp3 ... Joshy
|
|