TCP/IP 通信示例

TCP/IP 通信示例


Global String ReadData_P_All$, ReadData_P$(10), data$ '
Global Preserve Double x
Global Integer foundnumber_P

Function TCPServer
	   	SetNet #201, "192.168.0.1", 4000, CRLF, NONE, 0
	    OpenNet #201 As Client
	    WaitNet #201
	    Print "TCP Connected"
     	Integer i
    Do
         If ChkNet(201) > 0 Then
			  Line Input #201, ReadData_P_All$
	          Print "ReadData-p:", ReadData_P_All$
	          ParseStr ReadData_P_All$, ReadData_P$(), ","
	    		foundnumber_P = UBound(ReadData_P$())
	    	  Print "foundnumber_P=", foundnumber_P, "RP", Len(ReadData_P_All$)
		    	If ReadData_P$(UBound(ReadData_P$())) = "#" Then
    		  		For i = 0 To UBound(ReadData_P$())
    					ReadData_P$(i) = ""
					Next i
    		  	EndIf
		 EndIf
		If data$ <> "" Then
			Print #201, data$
			data$ = ""
		EndIf
    Loop
Fend


你可能感兴趣的:(TCP/IP 通信示例)