クラス定義部
コード: 全て選択
Class TCPClient
:
:
Public
' ========== サーバーをセットする ==========
' アドレスを1つずつ指定する場合
Function SetServer(nAddr1 As Byte, nAddr2 As Byte, nAddr3 As Byte, nAddr4 As Byte) As Long
Dim arrAddr[ELM(4)] = [nAddr1, nAddr2, nAddr3, nAddr4] As Byte
server = This.SetServer(arrAddr, 4)
SetServer = (server <> NULL)
End Function
' ホスト名で指定する場合
Function SetServer(strHost As *Byte) As Long
server = gethostbyname(strHost)
SetServer = (server <> NULL)
End Function
' ========== ポートをセットする ==========
' ポート番号で指定する場合
Function SetPort(nPort As Word)(strProtocol As *Byte) As Long
port = getservbyport(htons(nPort) As Long, strProtocol)
SetPort = (port <> NULL)
End Function
' サービス名で指定する場合(例:"http")
Function SetPort(strService As *Byte)(strProtocol As *Byte) As Long
port = getservbyname(strService, strProtocol)
SetPort = (port <> NULL)
End Function
:
:
End Class
コード: 全て選択
Dim tcpc As TCPClient
tcpc.SetServer("www.activebasic.com")
tcpc.SetPort("http")
AB4.21、4.24、5.00β4のいずれも同様です。