0

i have made the following code but i am not receiving any thing.

i want to recieve stock data from my broker server.

borker has given certain protocol to send msg like

sending msg

DataLength = 196|Transcode = 1|LoginId = _83|MemberPassword = 12345|TradingPassword = 67895| IP = 192.168.82.55 |Reserved = |

and response

DataLength = 508|Transcode = 1|StatusCode = 0|Message = SUCCESS|Client Info List = A Khan,123456,W12345|Reserved = |

But i am not receiving any response

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        private TcpClient client;


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           client = new TcpClient();
            client.Connect("192.168.43.141", 8000);
            Stream str = client.GetStream();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            NetworkStream serverStream = client.GetStream();
            byte[] outStream = System.Text.Encoding.ASCII.GetBytes(textBox1.Text + "$");
            serverStream.Write(outStream, 0, outStream.Length);
            serverStream.Flush();

            byte[] inStream = new byte[10025];
            serverStream.Read(inStream, 0, (int)client.ReceiveBufferSize);
            string returndata = System.Text.Encoding.ASCII.GetString(inStream);

            textBox2.Text = returndata;
            textBox2.Focus();
            textBox1.Clear();

        }



    }


}
supa pati
  • 63
  • 8
  • 2
    Check this answer [What is the correct way to read from NetworkStream in .NET](http://stackoverflow.com/questions/13097269/what-is-the-correct-way-to-read-from-networkstream-in-net) – Sergii Zhevzhyk Dec 15 '15 at 17:24
  • 1
    Have you considered using a packet sniffer app like Fiddler to watch what's actually being sent and received over the wire? I find that very useful when doing network calls. – Matt Hogan-Jones Dec 15 '15 at 17:29
  • my server is on local machine so is it possible to fiddler to watch whats being and sent – supa pati Dec 15 '15 at 17:43

0 Answers0