1

I´m programming a client/server application in c#

My code:

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


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {   }

        private void button1_Click(object sender, EventArgs e)
        {
            ///openfile
            OpenFileDialog file = new OpenFileDialog();
            if (file.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = file.FileName;
            }
        }

        private void label2_Click(object sender, EventArgs e)
        {   }

        private void label3_Click(object sender, EventArgs e)
        {   }

        private void button2_Click(object sender, EventArgs e)
        {
            //Socket send = new Socket(addressFamily.internetwork,                                    
            socketType.stream, protocolType.tcp);
            Socket send = new Socket(AddressFamily.InterNetwork,                                    
            SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint port = new 
            IPEndPoint(IPAddress.Parse(ip.Text),int.Parse(Port.Text));
            send.Send(port);
        }

        private void Form1_Load(object sender, EventArgs e)
        {   }

        private void label4_Click(object sender, EventArgs e)
        {   }

        private void label3_Click_1(object sender, EventArgs e)
        {   }
    }
}

and my error is :

Error 2 The best overloaded method match System.Net.Sockets.Socket.Send(System.Collections.Generic.IList>)' has some invalid arguments C:\Users\Acer\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 53 13 WindowsFormsApplication1

and Error 3 Argument 1: cannot convert from 'System.Net.IPEndPoint' to 'System.Collections.Generic.IList>' C:\Users\Acer\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 53 23 WindowsFormsApplication1

MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111
Compo_corp
  • 19
  • 2

1 Answers1

0

The IpEndPoint does not belong into the Send method. This method wants data to be transmitted. The EndPoint belongs into the Connect method.

Hence your error message.

You surely want to connect first, before trying to send data:

send.Connect(port);

picture or every files

If you want to send pictures via socket you should have a look at this post

Mong Zhu
  • 23,309
  • 10
  • 44
  • 76