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

Recommended Answers

All 3 Replies

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

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

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]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.