Web Service Error: Only one usage of each socket address (protocol/network address/port) is normally permitted

on Jan 31, 2018 12:50 AM

Hi i am geeting this error i hosting listner code in amazon webservice

this is console application when i publish and run this code i got this error when i hosted this code in amazon server

Only one usage of each socket address (protocol/network address/port) is normally permitted

this my code help me to solve this issue

using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Json;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace New_Server_Listener_Code
    class Program
        private static string URI = "xxx";
        private static byte[] _buffer = new byte[1024];
        private static List<Socket> _clientSockets= new List<Socket>();
        private static Socket _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        static void Main(string[] args)
        private static void SetupServer()
            Console.WriteLine("Setting up Server..");
            _serverSocket.Bind(new IPEndPoint(IPAddress.Any, 12121));
            _serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), null);
        private static void AcceptCallback(IAsyncResult AR)
            Socket socket = _serverSocket.EndAccept(AR);
            socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), socket);
            _serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), null);
        private static void ReceiveCallback(IAsyncResult AR)
            Socket socket = (Socket)AR.AsyncState;
            int received = socket.EndReceive(AR);
            byte[] dataBuf = new byte[received];
            Array.Copy(_buffer, dataBuf, received);
            String response = String.Empty;
            response = Encoding.ASCII.GetString(dataBuf);
            Console.WriteLine("Received:" + response);
                using (WebClient wc = new WebClient())
                    string Request = "SelectionType=Request&DataValue=" + response + "";
                    wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                    string HtmlResult = wc.UploadString(URI, Request);
                    var json = JsonObject.Parse(HtmlResult);
            catch (WebException ex)


Download FREE API for Word, Excel and PDF in ASP.Net: Download