$PBExportHeader$u_tabpg_tcp_send.sru $PBExportComments$Base tabpage object forward global type u_tabpg_tcp_send from u_tabpg end type type cb_sendblob from commandbutton within u_tabpg_tcp_send end type type cb_reset from commandbutton within u_tabpg_tcp_send end type type lb_msgs from listbox within u_tabpg_tcp_send end type type st_4 from statictext within u_tabpg_tcp_send end type type cb_send from commandbutton within u_tabpg_tcp_send end type type sle_hostname from singlelineedit within u_tabpg_tcp_send end type type st_1 from statictext within u_tabpg_tcp_send end type type st_3 from statictext within u_tabpg_tcp_send end type type sle_message from singlelineedit within u_tabpg_tcp_send end type type st_2 from statictext within u_tabpg_tcp_send end type type sle_port from singlelineedit within u_tabpg_tcp_send end type end forward global type u_tabpg_tcp_send from u_tabpg string text = "TCP Send" cb_sendblob cb_sendblob cb_reset cb_reset lb_msgs lb_msgs st_4 st_4 cb_send cb_send sle_hostname sle_hostname st_1 st_1 st_3 st_3 sle_message sle_message st_2 st_2 sle_port sle_port end type global u_tabpg_tcp_send u_tabpg_tcp_send type prototypes end prototypes type variables end variables on u_tabpg_tcp_send.create int iCurrent call super::create this.cb_sendblob=create cb_sendblob this.cb_reset=create cb_reset this.lb_msgs=create lb_msgs this.st_4=create st_4 this.cb_send=create cb_send this.sle_hostname=create sle_hostname this.st_1=create st_1 this.st_3=create st_3 this.sle_message=create sle_message this.st_2=create st_2 this.sle_port=create sle_port iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.cb_sendblob this.Control[iCurrent+2]=this.cb_reset this.Control[iCurrent+3]=this.lb_msgs this.Control[iCurrent+4]=this.st_4 this.Control[iCurrent+5]=this.cb_send this.Control[iCurrent+6]=this.sle_hostname this.Control[iCurrent+7]=this.st_1 this.Control[iCurrent+8]=this.st_3 this.Control[iCurrent+9]=this.sle_message this.Control[iCurrent+10]=this.st_2 this.Control[iCurrent+11]=this.sle_port end on on u_tabpg_tcp_send.destroy call super::destroy destroy(this.cb_sendblob) destroy(this.cb_reset) destroy(this.lb_msgs) destroy(this.st_4) destroy(this.cb_send) destroy(this.sle_hostname) destroy(this.st_1) destroy(this.st_3) destroy(this.sle_message) destroy(this.st_2) destroy(this.sle_port) end on event ue_pagechanged;call super::ue_pagechanged;sle_hostname.SetFocus() end event event destructor;call super::destructor;of_setreg("tcp_send_hostname", sle_hostname.text) of_setreg("tcp_send_port", sle_port.text) of_setreg("tcp_send_message", sle_message.text) end event event ue_postopen;call super::ue_postopen;String ls_hostname ls_hostname = gn_ws.of_GetHostName() sle_hostname.text = of_getreg("tcp_send_hostname", ls_hostname) sle_port.text = of_getreg("tcp_send_port", "") sle_message.text = of_getreg("tcp_send_message", "") end event type cb_sendblob from commandbutton within u_tabpg_tcp_send integer x = 37 integer y = 704 integer width = 480 integer height = 100 integer taborder = 60 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Send a Blob" end type event clicked;Blob lblb_header, lblb_filedata Integer li_fnum, li_rtn Long ll_bytes, ll_SendBufSize, ll_last, ll_BytesRecvd String ls_errmsg, ls_hostname, ls_fullname String ls_filename, ls_datalen, ls_reply UInt lui_port ULong lul_socket SetPointer(HourGlass!) ls_hostname = sle_hostname.text If ls_hostname = "" Then sle_hostname.SetFocus() MessageBox("Edit Error", "Server Host Name is required!") Return End If lui_port = Long(sle_port.text) If lui_port = 0 Then sle_port.SetFocus() MessageBox("Edit Error", "Server Port is required!") Return End If // get the file name li_rtn = GetFileOpenName("Select File", & ls_fullname, ls_filename, "", & "All files (*.*),*.*") If li_rtn < 1 Then Return SetPointer(HourGlass!) // check the max data size ll_SendBufSize = gn_ws.of_GetSendBufSize() If FileLength(ls_fullname) > ll_SendBufSize Then MessageBox("Edit Error", & "The file is larger than the maximum TCP " + & "send size of " + String(ll_SendBufSize) + & " bytes. You must send the data in parts and " + & "combine them at the destination!", StopSign!) Return End If // get a file into a blob li_fnum = FileOpen(ls_fullname, StreamMode!) If li_fnum > 0 Then ll_bytes = FileRead(li_fnum, lblb_filedata) FileClose(li_fnum) lb_msgs.AddItem("Bytes to send: " + String(ll_bytes, "#,##0")) If ll_bytes < 1 Then MessageBox("FileReadEx", "Failed!", StopSign!) Return End If Else MessageBox("FileOpen", "Failed!", StopSign!) Return End If // connect to the host lul_socket = gn_ws.of_Connect(ls_hostname, lui_port) If lul_socket = 0 Then ls_errmsg = gn_ws.of_GetLastError() lb_msgs.AddItem(ls_errmsg) MessageBox("Connect to Host Failed", & ls_errmsg, StopSign!) Return End If // send the datalength + filename lblb_header = Blob(String(Len(lblb_filedata)) + & "|" + ls_filename + "|") If Not gn_ws.of_Send(lul_socket, lblb_header) Then ls_errmsg = gn_ws.of_GetLastError() lb_msgs.AddItem(ls_errmsg) gn_ws.of_CloseSocket(lul_socket) MessageBox("Send Datalen Failed", & ls_errmsg, StopSign!) Return End If // send the message If Not gn_ws.of_Send(lul_socket, lblb_filedata) Then ls_errmsg = gn_ws.of_GetLastError() lb_msgs.AddItem(ls_errmsg) gn_ws.of_CloseSocket(lul_socket) MessageBox("Send Message Failed", & ls_errmsg, StopSign!) Return End If // receive a reply ll_BytesRecvd = gn_ws.of_Recv(lul_socket, ls_reply) If ll_BytesRecvd > 0 Then lb_msgs.AddItem("Reply Recvd: " + ls_reply) Else ls_errmsg = gn_ws.of_GetLastError() lb_msgs.AddItem(ls_errmsg) gn_ws.of_CloseSocket(lul_socket) MessageBox("Receive Reply Failed", & ls_errmsg, StopSign!) Return End If // disconnect from the host gn_ws.of_CloseSocket(lul_socket) end event type cb_reset from commandbutton within u_tabpg_tcp_send integer x = 951 integer y = 1248 integer width = 334 integer height = 100 integer taborder = 70 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Reset Msgs" end type event clicked;lb_msgs.Reset() end event type lb_msgs from listbox within u_tabpg_tcp_send integer x = 1353 integer y = 96 integer width = 1541 integer height = 1252 integer taborder = 80 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 boolean hscrollbar = true boolean vscrollbar = true boolean sorted = false borderstyle borderstyle = stylelowered! end type type st_4 from statictext within u_tabpg_tcp_send integer x = 1353 integer y = 32 integer width = 283 integer height = 60 integer textsize = -8 integer weight = 700 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Messages:" boolean focusrectangle = false end type type cb_send from commandbutton within u_tabpg_tcp_send integer x = 37 integer y = 544 integer width = 480 integer height = 100 integer taborder = 50 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Send a String" end type event clicked;Long ll_last, ll_BytesRecvd String ls_hostname, ls_message, ls_peername, ls_reply UInt lui_port, lui_peerport ULong lul_socket SetPointer(HourGlass!) ls_hostname = sle_hostname.text If ls_hostname = "" Then sle_hostname.SetFocus() MessageBox("Edit Error", "Server Host Name is required!") Return End If lui_port = Long(sle_port.text) If lui_port = 0 Then sle_port.SetFocus() MessageBox("Edit Error", "Server Port is required!") Return End If ls_message = sle_message.text If ls_message = "" Then sle_message.SetFocus() MessageBox("Edit Error", "Message is required!") Return End If // connect to the host lul_socket = gn_ws.of_Connect(ls_hostname, lui_port) If lul_socket = 0 Then ls_message = gn_ws.of_GetLastError() lb_msgs.AddItem(ls_message) MessageBox("Connect to Host Failed", & ls_message, StopSign!) Return End If // get address of machine at the other end of the connection gn_ws.of_GetPeerName(lul_socket, ls_peername, lui_peerport) If ls_peername <> "" Then lb_msgs.AddItem("Peer: " + ls_peername) End If // send the message gn_ws.of_SetUnicode(w_main.cbx_setunicode.checked) If Not gn_ws.of_Send(lul_socket, ls_message) Then ls_message = gn_ws.of_GetLastError() lb_msgs.AddItem(ls_message) gn_ws.of_CloseSocket(lul_socket) MessageBox("Send Message Failed", & ls_message, StopSign!) Return End If // receive a reply ll_BytesRecvd = gn_ws.of_Recv(lul_socket, ls_reply) If ll_BytesRecvd > 0 Then lb_msgs.AddItem("Msg Recvd: " + ls_reply) Else ls_message = gn_ws.of_GetLastError() lb_msgs.AddItem(ls_message) gn_ws.of_CloseSocket(lul_socket) MessageBox("Receive Reply Failed", & ls_message, StopSign!) Return End If // disconnect from the host gn_ws.of_CloseSocket(lul_socket) end event type sle_hostname from singlelineedit within u_tabpg_tcp_send integer x = 219 integer y = 104 integer width = 1065 integer height = 80 integer taborder = 10 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type type st_1 from statictext within u_tabpg_tcp_send integer x = 37 integer y = 116 integer width = 160 integer height = 60 integer textsize = -8 integer weight = 700 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Host:" boolean focusrectangle = false end type type st_3 from statictext within u_tabpg_tcp_send integer x = 37 integer y = 356 integer width = 270 integer height = 60 integer textsize = -8 integer weight = 700 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Message:" boolean focusrectangle = false end type type sle_message from singlelineedit within u_tabpg_tcp_send integer x = 37 integer y = 416 integer width = 1248 integer height = 80 integer taborder = 40 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type event losefocus;cb_send.Default = False end event event getfocus;cb_send.Default = True end event type st_2 from statictext within u_tabpg_tcp_send integer x = 37 integer y = 236 integer width = 142 integer height = 60 integer textsize = -8 integer weight = 700 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Port:" boolean focusrectangle = false end type type sle_port from singlelineedit within u_tabpg_tcp_send integer x = 219 integer y = 224 integer width = 224 integer height = 80 integer taborder = 30 integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 integer limit = 5 borderstyle borderstyle = stylelowered! end type
File: u_tabpg_tcp_send.sru
Size: 12361
Date: Mon, 31 Dec 2018 21:14:39 +0100
Size: 12361
Date: Mon, 31 Dec 2018 21:14:39 +0100
- u_tabpg u_tabpg_tcp_send(sru)
- commandbutton cb_sendblob
- commandbutton cb_reset
- listbox lb_msgs
- statictext st_4
- commandbutton cb_send
- singlelineedit sle_hostname
- statictext st_1
- statictext st_3
- singlelineedit sle_message
- statictext st_2
- singlelineedit sle_port