|   1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 |  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
|
!
 
 
-
|
!
 
 
 
 
-
|
!
 
 
 
 
-
|
|
|
|
|
!
 
 
 
 
 
-
|
|
|
|
|
|
|
|
|
|
-
|
|
!
 
 
 
 
 
 
 | #module
#include "pcbnet2.as"
#deffunc NetworkInit
    netinit
return
#defcfunc NetworkGetIP str p1, int p2, str p3, str p4, str p5
    
    dim flg, 1
    dim size, 1
    dim p, 1
    sdim buf, 1024, 2
    
    TcpOpen _gPID_, p1, p2
    if (stat != 0) {
        dialog "ソケット生成に失敗しました", 1 : stop
    }
    repeat
        TcpIsCon _gPID_
        if (stat != 0) {
            break
        }
        wait 10
    loop
    
    TcpPut "GET "+p3+" HTTP/1.0\nHost:???\nUser-Agent:???\n\n", _gPID_
    if (stat != 0) {
        dialog "パケット送信に失敗しました", 1 : stop
    }
    
    repeat
        
        TcpCount size, _gPID_
        if (size > 0)&(stat != 1) {
            TcpGet buf(0), size+1, _gPID_
            : buf(1) = buf(1)+buf(0)
            
            : flg = 1
            break
        }
        wait 10
    loop
    
    TcpClose _gPID_
    
    if (flg != 0) {
        
        
        : p = instr(buf(1), 0, "\n\n")
        : buf(1) = strmid(buf(1), p, strlen(buf(1)))
        : p = instr(buf(1), 0, "<"+p4+">")
        : buf(1) = strmid(buf(1), p+strlen(p4)+2, strlen(buf(1)))
        : p = instr(buf(1), 0, "</"+p4+">")
        : buf(1) = strmid(buf(1), 0, p)
        : p = instr(buf(1), 0, ""+p5+"")
        : buf(1) = strmid(buf(1), p+strlen(p5), strlen(buf(1)))
    } else {
        
        : buf(1) = ""
    }
return buf(1)
 
#global
 
NetworkInit
mes NetworkGetIP("checkip.dyndns.org", 80, "/", "body", "Current IP Address:")
 |