Click here to Skip to main content
15,907,906 members

Comments by Savad.k.s (Top 4 by date)

Savad.k.s 24-Nov-15 3:02am View    
but i have a console application for this. its working fine and the out put is "ffffffff30" somthing like that
=======
console application sourcecode
======

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;

//client

namespace ConsoleApplication9
{
class Program
{
static Socket sck;
static void Main(string[] args)
{
sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse("192.168.0.177"), 80);

try
{
sck.Connect(localEndPoint);
}
catch
{
Console.Write("Unable to Connect \r\n");
Main(args);
}
Console.Write("Enter Text: ");
string text=Console.ReadLine();
byte[] data = Encoding.ASCII.GetBytes(text);

sck.Send(data);
Console.Write("Data Sent!\r\n");
Console.Write("Press any key to Continue...");
string l;

Console.Read();

byte[] bytes = new byte[15];

sck.Receive(bytes);
Console.WriteLine(Encoding.UTF8.GetString(bytes));

sck.Close();
Console.Read();





}

}
}
Savad.k.s 23-Nov-15 8:15am View    
sorry to ask.. but "int bytesRec = sender.Receive(bytes);" is there any way to change that int to string
Savad.k.s 23-Nov-15 8:13am View    
I know it is silly ... sorry about that. i am just a stater in programming world
Savad.k.s 23-Nov-15 1:05am View    
The think is i am new to this network programming... for past few years i am done only standalone accounting programs. This is a new to me. I have no idea how to accept the data from a network socket.Tired of googling cant find satisfying answer. Just tell how to accept the data or bytes and how to store into a string variable... Thanks in advance