Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WCF socket Silverlight5 , +
please help me friends
i have code below:
when getting to "worker = ((Service1)ar.AsyncState).EndAccept(ar);"
take a error:The remote server returned an error: NotFound.
or exceed...time out error
public MainPage()
        {
            InitializeComponent();
            elements.Add(new BinaryMessageEncodingBindingElement());
            elements.Add(new HttpTransportBindingElement());        
            var binding = new CustomBinding(elements);            
            var tranportElement = binding.Elements.Find<HttpTransportBindingElement>();
            tranportElement.MaxReceivedMessageSize = 2147483647;
            tranportElement.MaxBufferSize = 2147483647;
            tranportElement.ManualAddressing = false;
            var cf = new ChannelFactory<Service1>(binding, new EndpointAddress           ("http://localhost:1471/Service1"));
            uiThread = SynchronizationContext.Current;
            channel = cf.CreateChannel();    
            try
            {
       channel.BeginAccept("192.168.1.3", 4531, new AsyncCallback(AcceptCallBack), channel);
            }
            catch
            {}
	}
        private void AcceptCallBack(IAsyncResult ar)
        {
            try
            {
                if (ar.IsCompleted)
                {
                    worker = ((Service1)ar.AsyncState).EndAccept(ar);
                    uiThread.Post(UpdateUi, worker);
                    //channel.BeginReceive(worker, new AsyncCallback(ReceiveCallBack),   channel);
                }
            }
            catch
            {
                Close(ar);
            }
        }
code of my project.web
 public MySocket Accept(string Ip,int Port)
        {
            worker = new MySocket();
            Socket SocketAccept =null;
            try
            {
                System.Net.ServicePointManager.DefaultConnectionLimit = 20;
                serverReceive = new IPEndPoint(IPAddress.Parse(Ip), Port);
                Socket  SocketReceive = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                SocketAccept = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                SocketReceive.Bind(serverReceive);
                SocketReceive.Listen(2);
                worker.socketOut = SocketReceive.Accept();                
                worker.strOut = "accept";                
                
            }
            catch
            {
                worker = new MySocket();
                worker.socketOut = SocketAccept;
                CloseConnect(worker);
            }
 
            return worker;
        }
webconfig is:
<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="manomoshaverConnectionString" connectionString="Data Source=.;Initial Catalog=manomoshaver;Integrated Security=True"
        providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <diagnostics>
      <endToEndTracing activityTracing="true" />
    </diagnostics>
    <extensions>
      <behaviorExtensions>
        <add name="silverlightFaults"
             type="prjManomoshaver.Web.SilverlightFaultBehavior, prjManomoshaver.Web" />
      </behaviorExtensions>
    </extensions>
    <behaviors>
      <endpointBehaviors>
        <behavior name="SilverlightFaultBehavior">
          <!--<silverlightFaults />-->
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="prjManomoshaver.Web.Service1.customBinding0" receiveTimeout="00:05:00">
          <binaryMessageEncoding  maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" maxSessionSize="2147483647"/>
          <httpTransport />
        </binding>
      </customBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
        multipleSiteBindingsEnabled="true" />
    <services>
      <service name="prjManomoshaver.Web.Service1">
        <endpoint address="" binding="customBinding" bindingConfiguration="prjManomoshaver.Web.Service1.customBinding0"
            contract="prjManomoshaver.Web.Service1" behaviorConfiguration="SilverlightFaultBehavior" />        
 
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
  </configuration>
Posted 26-Apr-13 21:24pm
armanr493
Edited 26-Apr-13 21:30pm
v2
Comments
Sandeep Mewara at 27-Apr-13 6:41am
   
Is the issue during deployment?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 BillWoodruff 170
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 27 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100