robotics company robot company  

Go Back   Trossen Robotics Community > Community Tutorials > Introduction

Home Submit Tutorial What's New What's Popular Search

Reading and Writing TCP Sockets in C#
Old 08-28-2008 11:59 AM
Adrenalynn
Adrenalynn is offline
Banned from posting too much :-)
 
Category: Introduction
Views: 5,119
Replies: 0
Difficulty: Beginner
Estimated Time: 15 mins
Skills Required: Beginning C# programming
Tools Required: Microsoft C# compiler (Express is fine)
Untested on Mono, but should work.
The Setup:

This VERY simple stand-alone console app will listen on a free port and echo one line sent from a client to the console, then wait for a newline to exit.

Not production code, just the cheapest easiest way I know of to open a listening TCP socket and grabbing some data sent by the client.

Let's start a new session. Launch MS C# of your favorite flavor. Select File -> New Project, Select Console Application from the Installed Templates, give it a name (like ConsoleTCPServer) and paste the following code into it:

(Page 1 of 5)
__________________
I Void Warranties™

CCTV Camera Systems and Security Camera Accessories by eMS. Ignore the CCTV Camera linkage. Just taking advantage of an inbound link opportunity...
Tags: None




 


All times are GMT -5. The time now is 09:44 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.