10.2.2
Auszüge Beispielcode der Anwenderapplikation in C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Web;
namespace RF182CApp
public partial class MainForm : Form
{
// Socket to realise TCP/IP conncetion
private Socket Connection = null;
// connectet (true) or not (false)
private bool ConnectionState = false;
// buffer for received data
private String ReceiveBuffer = "";
// Indicator for an error in asynchronous receive threads
bool AsyncError = false;
public MainForm()
{
InitializeComponent();
}
/* This routine is called when the window in initialized. */
private void MainForm_Load(object sender, EventArgs e)
{
//We're not connected at the beginning
SetConnectionState(false);
}
/* This routine is called when the Connect / Disconnect button
* is clicked.
* */
private void bConnect_Click(object sender, EventArgs e)
{
if (ConnectionState == true) //already connected --> close connection
{
/* Connection may be dsiposed alread (i.e. if an error
* occured before.
* */
if (Connection != null)
{
Kommunikationsmodul RF182C
Betriebsanleitung, 10/2010, J31069-D0204-U001-A2-0018
//Close the socket
Connection.Close();
Beispiele/Applikationen
10.2 Anwenderapplikation RF182C
93