954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

need help TCPIP socket

hi everyone, i am new in C#. and i had some problem on socket(TCP) program. i want to write a program that receive a RFID reader data. but i never learn about socket programing. can anyone help me... thank you

fllee
Newbie Poster
2 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

Well, is this RFID reader transmitting over sockets ?
Most RFID readers are serial (Com) or USB devices. When incorporated into a hand-held or POS unit the information surrounding the RFID is usually wrapped along with other information as to the location (register, etc).

So your question must be expanded to included the source of the TCP data.
Setting up a socket is not all too difficult. Managing the data that it receives, making authenticated connection to the other end, protocol to use, port, etc. that is where some planning and information come in to make it a successul project. Do you have all this information ?

Is the data being transmitted / received in plain text ?
Is in coming in as a delimited string ?
Is it an XML stream ?

Once you have all the needed information, and pass the code you have done so far, I might give you a helping hand.

// Jerry

JerryShaw
Posting Pro in Training
465 posts since Nov 2006
Reputation Points: 69
Solved Threads: 75
 

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.Diagnostics;


namespace TCPIP
{
public partial class Form1 : Form
{
//Establish the local endpoint for the socket
IPEndPoint ip = new IPEndPoint(IPAddress.Parse("192.168.0.2"), 9999);
//Create a TCPIP socket
Socket soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

public Form1()
{
InitializeComponent();
}


private void btnConnect_Click(object sender, EventArgs e)
{
try
{
soc.Connect(ip); //socket connected
byte[] data = new byte[1024];
soc.Receive(data);
//int length=BitConverter.ToInt32(data,0);
string sD = Encoding.ASCII.GetString(data, 0,length);
MessageBox.Show(sD);
}
catch (SocketException excp)
{
MessageBox.Show(excp.Message);
return;
}
}
} that the code i had done.. but not working. actually what i want to do is receiving data from server(reader) only. thank for reply

fllee
Newbie Poster
2 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 
hi everyone, i am new in C#. and i had some problem on socket(TCP) program. i want to write a program that receive a RFID reader data. but i never learn about socket programing. can anyone help me... thank you


i am also same concept incase you got this solution can you pls mail me this id [email]....[/email]

jagadeeshwaran
Newbie Poster
2 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You