Click here to Skip to main content
15,889,116 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to get md5 value or alike from arraylist? Pin
lvq68410-Oct-09 21:52
lvq68410-Oct-09 21:52 
QuestionDatabase build in c# Pin
JollyMansArt10-Oct-09 5:39
JollyMansArt10-Oct-09 5:39 
AnswerRe: Database build in c# Pin
Henry Minute10-Oct-09 5:57
Henry Minute10-Oct-09 5:57 
AnswerRe: Database build in c# Pin
Md. Marufuzzaman10-Oct-09 5:57
professionalMd. Marufuzzaman10-Oct-09 5:57 
QuestionRe: Database build in c# Pin
JollyMansArt10-Oct-09 6:34
JollyMansArt10-Oct-09 6:34 
AnswerRe: Database build in c# Pin
Md. Marufuzzaman10-Oct-09 6:50
professionalMd. Marufuzzaman10-Oct-09 6:50 
AnswerRe: Database build in c# Pin
Mycroft Holmes10-Oct-09 12:53
professionalMycroft Holmes10-Oct-09 12:53 
QuestionWhy I can send only one string to server-TCP Pin
Aljaz11110-Oct-09 4:10
Aljaz11110-Oct-09 4:10 
Hi.
I have problems..when i send string from client to server, server recieves string and sends it back to client. Works fine for first time. But now i don't know why i can't send it again, lets say different..

Here is code for server:
public server()
        {
            
           
            InitializeComponent();
           
            
        }

        private void server_Load(object sender, EventArgs e)
        {
            
            IPAddress ipAd = IPAddress.Parse("127.0.0.1");
            TcpListener myList = new TcpListener(ipAd, int.Parse("1111"));
            myList.Start();


            try
            {
                
                
                

                Socket socketForClient = myList.AcceptSocket();

                Console.WriteLine("Odjemalec povezan " + socketForClient.RemoteEndPoint.ToString());
                NetworkStream networkStream = new NetworkStream(socketForClient);
                StreamWriter streamWriter = new StreamWriter(networkStream);
                StreamReader streamReader = new StreamReader(networkStream);
                line = streamReader.ReadLine();
                Console.WriteLine("Sprejeto: " + line);
                textBox1.Text = line;
                streamWriter.WriteLine(line);
                Console.WriteLine("Poslano: " + line);
                
                streamWriter.Flush();
                Console.WriteLine();
                
                //socketForClient.Close();
                //myList.Stop();

            }
            catch (Exception x)
            {
                Console.WriteLine("Error..... " + x.StackTrace);
            } 
}


Here is code for my server
private string _ip = String.Empty;
        private string _port = String.Empty;
        private int izbira;
        string novo;
        TcpClient odjemalec = new TcpClient();
        
        
        

        public client(string ip, string port)
        {
            InitializeComponent();
            this._ip = ip;
            this._port = port;
        }


        private void client_Load(object sender, EventArgs e)
        {



            try
            {
                
                IPAddress novip = IPAddress.Parse(_ip);
                Console.WriteLine("Povezujem ...");

                odjemalec.Connect(novip, int.Parse(_port));

                Console.WriteLine("Povezan");
                Console.Write("Vpiši besedilo: ");
                String line = Console.ReadLine();
 

                //odjemalec.Close();
            }
            catch (Exception x)
            {
                Console.WriteLine("Napaka: " + x.Message);
            }

        }

private void poslji()
        {


            if (comboBox1.SelectedIndex == 0) novo = "1";
            if (comboBox1.SelectedIndex == 1) novo="2";
            
            //novo = textbox();
            NetworkStream networkStream = odjemalec.GetStream();
            StreamReader streamReader = new StreamReader(networkStream);
            StreamWriter streamWriter = new StreamWriter(networkStream);
            streamWriter.WriteLine(novo);
            Console.WriteLine("Pošiljam sporočilo...");
            streamWriter.Flush();
            string s = streamReader.ReadLine();


            textBox1.Text = s;

            Console.WriteLine("Prejemam sporočilo...");
            Console.WriteLine(s);

            //streamReader.Close();
            //streamWriter.Close();
            //networkStream.Close();

            //odjemalec.Close();

                
                    
        }

        
        string textbox()
        {
            novo = textBox1.Text;
            return novo;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            poslji();
        }


Please help me that i would be able to send more than one time.
AnswerRe: Why I can send only one string to server-TCP Pin
Luc Pattyn10-Oct-09 5:29
sitebuilderLuc Pattyn10-Oct-09 5:29 
GeneralRe: Why I can send only one string to server-TCP Pin
Aljaz11110-Oct-09 6:12
Aljaz11110-Oct-09 6:12 
GeneralRe: Why I can send only one string to server-TCP Pin
Luc Pattyn10-Oct-09 6:17
sitebuilderLuc Pattyn10-Oct-09 6:17 
GeneralRe: Why I can send only one string to server-TCP Pin
Aljaz11110-Oct-09 7:34
Aljaz11110-Oct-09 7:34 
Question[Message Deleted] Pin
Fred 3410-Oct-09 4:03
Fred 3410-Oct-09 4:03 
AnswerRe: useful icon for developing desktop application Pin
Md. Marufuzzaman10-Oct-09 4:25
professionalMd. Marufuzzaman10-Oct-09 4:25 
QuestionDon't convert to the nearest decimal Pin
Etienne_12310-Oct-09 3:48
Etienne_12310-Oct-09 3:48 
AnswerRe: Don't convert to the nearest decimal Pin
Luc Pattyn10-Oct-09 3:53
sitebuilderLuc Pattyn10-Oct-09 3:53 
GeneralRe: Don't convert to the nearest decimal Pin
Etienne_12310-Oct-09 3:58
Etienne_12310-Oct-09 3:58 
GeneralRe: Don't convert to the nearest decimal Pin
Luc Pattyn10-Oct-09 4:09
sitebuilderLuc Pattyn10-Oct-09 4:09 
GeneralRe: Don't convert to the nearest decimal Pin
harold aptroot10-Oct-09 4:14
harold aptroot10-Oct-09 4:14 
GeneralRe: Don't convert to the nearest decimal Pin
Luc Pattyn10-Oct-09 5:26
sitebuilderLuc Pattyn10-Oct-09 5:26 
GeneralRe: Don't convert to the nearest decimal Pin
harold aptroot10-Oct-09 5:40
harold aptroot10-Oct-09 5:40 
GeneralRe: Don't convert to the nearest decimal Pin
Luc Pattyn10-Oct-09 6:05
sitebuilderLuc Pattyn10-Oct-09 6:05 
GeneralRe: Don't convert to the nearest decimal Pin
harold aptroot10-Oct-09 6:51
harold aptroot10-Oct-09 6:51 
GeneralRe: Don't convert to the nearest decimal Pin
Etienne_12310-Oct-09 5:44
Etienne_12310-Oct-09 5:44 
GeneralRe: Don't convert to the nearest decimal Pin
Henry Minute10-Oct-09 6:05
Henry Minute10-Oct-09 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.