Search Results

Search found 108 results on 5 pages for 'tcpclient'.

Page 4/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • Apple push Notification Feedback service Not working

    - by Yassmeen
    Hi, I am developing an iPhone App that uses Apple Push Notifications. On the iPhone side everything is fine, on the server side I have a problem. Notifications are sent correctly however when I try to query the feedback service to obtain a list of devices from which the App has been uninstalled, I always get zero results. I know that I should obtain one result as the App has been uninstalled from one of my test devices. After 24 hours and more I still have no results from the feedback service.. Any ideas? Does anybody know how long it takes for the feedback service to recognize that my App has been uninstalled from my test device? Note: I have another push notification applications on the device so I know that my app is not the only app. The code - C#: public static string CheckFeedbackService(string certaName, string hostName) { SYLogger.Log("Check Feedback Service Started"); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate); // Create a TCP socket connection to the Apple server on port 2196 TcpClient tcpClientF = null; SslStream sslStreamF = null; string result = string.Empty; //Contect to APNS& Add the Apple cert to our collection X509Certificate2Collection certs = new X509Certificate2Collection { GetServerCert(certaName) }; //Set up byte[] buffer = new byte[38]; int recd = 0; DateTime minTimestamp = DateTime.Now.AddYears(-1); // Create a TCP socket connection to the Apple server on port 2196 try { using (tcpClientF = new TcpClient(hostName, 2196)) { SYLogger.Log("Client Connected ::" + tcpClientF.Connected); // Create a new SSL stream over the connection sslStreamF = new SslStream(tcpClientF.GetStream(), true,ValidateServerCertificate); // Authenticate using the Apple cert sslStreamF.AuthenticateAsClient(hostName, certs, SslProtocols.Default, false); SYLogger.Log("Stream Readable ::" + sslStreamF.CanRead); SYLogger.Log("Host Name ::"+hostName); SYLogger.Log("Cert Name ::" + certs[0].FriendlyName); if (sslStreamF != null) { SYLogger.Log("Connection Started"); //Get the first feedback recd = sslStreamF.Read(buffer, 0, buffer.Length); SYLogger.Log("Buffer length ::" + recd); //Continue while we have results and are not disposing while (recd > 0) { SYLogger.Log("Reading Started"); //Get our seconds since 1970 ? byte[] bSeconds = new byte[4]; byte[] bDeviceToken = new byte[32]; Array.Copy(buffer, 0, bSeconds, 0, 4); //Check endianness if (BitConverter.IsLittleEndian) Array.Reverse(bSeconds); int tSeconds = BitConverter.ToInt32(bSeconds, 0); //Add seconds since 1970 to that date, in UTC and then get it locally var Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(tSeconds).ToLocalTime(); //Now copy out the device token Array.Copy(buffer, 6, bDeviceToken, 0, 32); string deviceToken = BitConverter.ToString(bDeviceToken).Replace("-", "").ToLower().Trim(); //Make sure we have a good feedback tuple if (deviceToken.Length == 64 && Timestamp > minTimestamp) { SYLogger.Log("Feedback " + deviceToken); result = deviceToken; } //Clear array to reuse it Array.Clear(buffer, 0, buffer.Length); //Read the next feedback recd = sslStreamF.Read(buffer, 0, buffer.Length); } SYLogger.Log("Reading Ended"); } } } catch (Exception e) { SYLogger.Log("Authentication failed - closing the connection::" + e); return "NOAUTH"; } finally { // The client stream will be closed with the sslStream // because we specified this behavior when creating the sslStream. if (sslStreamF != null) sslStreamF.Close(); if (tcpClientF != null) tcpClientF.Close(); //Clear array on error Array.Clear(buffer, 0, buffer.Length); } SYLogger.Log("Feedback ended "); return result; }

    Read the article

  • Implementing the transport layer for a SIP UAC

    - by Jonathan Henson
    I have a somewhat simple, but specific, question about implementing the transport layer for a SIP UAC. Do I expect the response to a request on the same socket that I sent the request on, or do I let the UDP or TCP listener pick up the response and then route it to the correct transaction from there? The RFC does not seem to say anything on the matter. It seems that especially using UDP, which is connection-less, that I should just let the listeners pick up the response, but that seems sort of counter intuitive. Particularly, I have seen plenty of UAC implementations which do not depend on having a Listener in the transport layer. Also, most implementations I have looked at do not have the UAS receiving loop responding on the socket at all. This would tend to indicate that the client should not be expecting a reply on the socket that it sent the request on. For clarification: Suppose my transport layer consists of the following elements: TCPClient (Sends Requests for a UAC via TCP) UDPClient (Sends Requests for a UAC vid UDP) TCPSever (Loop receiving Requests and dispatching to transaction layer via TCP) UDPServer (Loop receiving Requests and dispatching to transaction layer via UDP) Obviously, the *Client sends my Requests. The question is, what receives the Response? The *Client waiting on a recv or recvfrom call on the socket it used to send the request, or the *Server? Conversely, the *Server receives my requests, What sends the Response? The *Client? doesn't this break the roles of each member a bit?

    Read the article

  • Semantic coupling vs. large class

    - by user106587
    I have hardware I communicate with via TCP. This hardware accepts ~40 different commands/requests with about 20 different responses. I've created a HardwareProxy class which has a TcpClient to send and receive data. I didn't like the idea of having 40 different methods to send the commands/requests, so I started down the path of having a single SendCommand method which takes an ICommand and returns an IResponse, this results in 40 different SpecificCommand classes. The problem is this requires semantic coupling, i.e. the method that invokes SendCommand receives an IResponse which it has to downcast to SpecificResponse, I use a future map which I believe ensures the appropriate SpecificResponse, but I get the impression this code smells. Besides the semantic coupling, ICommand and IResponse are essentially empty abstract classes (Marker Interfaces) and this seems suspicious to me. If I go with the 40 methods I don't think I have broken the single responisbility principle as the responsibility of the HardwareProxy class is to act as the hardware, which has all of these commands. This route is just ugly, plus I'd like to have Asynchronous versions, so there'd be about 80 methods. Is it better to bite the bullet and have a large class, accept the coupling and MarkerInterfaces for a smaller soultuion, or am I missing a better way? Thanks.

    Read the article

  • CodePlex Daily Summary for Tuesday, June 08, 2010

    CodePlex Daily Summary for Tuesday, June 08, 2010New ProjectsAD CMS: CMS software project still in its initial development and design stage.Animated panel: Animated Panel is a WPF control that supports animation of its content on resize. Can be used in item controls (ListBox for example) as ItemsPanelT...Anurag Pallaprolu's Code Repository: Hi there, this is Anurag P.'s public repository which contains most of c++ language examples and many command line(only) applications. Well , plea...atfas: atfasBibleNotes: A small application that uses BibleGateway to lookup scripture and add notes to themCarRental: How to Rent A Car.Food Innovation: This is the Food Innovation project.Generic Validation.NET: Generic Validation.NET is a flexible lightweight validation library for .NET, that can be used by any .NET project: ASP.NET Web Forms, ASP.NET MVC,...Komoi: Komoi is an app that will bring on a new form of web comic delivery.Liekhus Entity Framework XAF Extensions: Entity Framework extensions to support DevExpress eXpress Application Framework (XAF) code generation by Patrick Liekhus.Marketing: Desing Automation Marketing FlowMediaCoder.NET: MediaCoder.NET makes it easy for normal PC users to convert media files to other formats. It is developed in Visual Basic.NETMemetic NPC Behavior Toolkit: This is a library based on the NeverWinter Nights' Memetic AI Toolkit by William Bull. This is an attempt at creating a C# edition of this brillia...MeVisLab QT VR Export: -Mudbox: This project for personal test. Prog2: wi ss10 2010 PSAdmin: PSAdmin is a web based administration tool that allows the easy execution of Windows PowerShell scripts within your environment.RIA Services Essentials: The RIA Services Essentials project contains sample applications/extensions demonstrating using and extending WCF RIA Services v1.SCSM Service Request: The Service Request project defines a new work item class called 'Service Request' and the corresponding form for that work item class. It is a go...SFTP Component for .NET CSharp, VB.NET, and ASP.NET: The Ultimate SSH Secure File Transfer (SFTP) .NET Component offers a comprehensive interface for SFTP, enabling you to quickly and easily incorpora...shitcore: Application demonstrating how to turn a crappy application into something useful. Read more about the refactoring in http://blog.gauffin.com (sear...SystemCentered Operations Manager Reporting: SystemCentered Reporting give Microsoft System Center Operations Manager administrators an extended set of performance reports aimed towards all us...TokyoTyrantClient: makes it easier for c# developer to write code to connect the tokyo tyrant. it support: 1.utf-8 encode 2.tcpClient pool 3.rich setting about tc...Ultimate FTP Component for .NET C#, VB.NET and ASP.NET: Ultimate FTP is a 100%-managed .NET class library that adds powerful and comprehensive File Transfer capabilities to your .NET applications. WCF 4 Templates for Visual Studio 2010: WCF 4 templates for Visual Studio 2010 providing a scenario-driven starting point.XCube: XCube is a basic command line interface, with support for files, user accounts(only in the GUI), and variables(only in DevMode). It is developed in...New ReleasesAdd-ons for EPiServer Relate+: EPiXternal.RelatePlus.Properties 0.1.0.0 Alpha: This is the Alpha release of EPiXternal.RelatePlus.Properties. The download is in the form of an .epimodule file that you can install with EPiServe...Add-ons for EPiServer Relate+: EPiXternal.RelatePlus.WebControl 0.1.0.0 Alpha: This is the Alpha release of EPiXternal.RelatePlus.WebControls. The download is in the form of an .epimodule file that you can install with EPiServ...Animated panel: AnimatedPanel v1: First version of AnimatedPanel.Anurag Pallaprolu's Code Repository: C.L.O.S.E - V3: C.L.O.S.E - V3 Smaller than ever. More Useful than ever Run only CLOSEV3.exeAnurag Pallaprolu's Code Repository: FLTK - 1.3.X: The Fast Lightining Tool Kit is back. This is the FLTK 1.3.X Tar ballAnurag Pallaprolu's Code Repository: KBHIT Function Code: This is a sample to teach about kbhit()Browser Gallese: Browser 1.0.0.15: Continua l'era del browser opensource con una novità:ho impiantato il P2P online. Adesso il browser ha bisogno di Java. Se non lo avete,cliccate qu...CC.Hearts Screen Saver: CC.Hearts Screen Saver 1.0.10.607: This is the initial release of CC.Hearts Screen Saver. Marking as stable but limited testing at this point so feedback is greatly welcomed.Community Forums NNTP bridge: Community Forums NNTP Bridge V32: Release of the Community Forums NNTP Bridge to access the social and anwsers MS forums with a single, open source NNTP bridge. This release has ad...DotNetNuke® Skins: Default.css (beta): About The team has put together a cleaned up and optimized default.css file as a first step in moving toward more efficient CSS usage. Ideally, th...Dynamic Survey Forms - SharePoint Web Part: Code Fix 06-07-2010: Fix for editing existing forms Add: Requiered field option Add: Requiered field validation on submitFloe IRC Client: Floe 1.0 (2010-06): NOTE: You may have to uninstall your existing version for this installer to work properly. - Added /QUOTE command - Fixed bug where new message in...Folder Bookmarks: Folder Bookmarks 1.6.2.1: The latest version of Folder Bookmarks (1.6.2.1), with new Mini-Menu UI changes (1.3). Once you have extracted the file, do not delete any files/f...Food Innovation: Food Innovation 1.0: This is the V1.0 release.HERB.IQ: Alpha 0.1 Source code release 7: Alpha 0.1 Source code release 7 (skipped uploading 6)Liekhus Entity Framework XAF Extensions: Version 1.1.0: Initial project release. Ported the XAFDSL tool into the Entity Framework and made it work with the Visual Studio 2010 extensions.LogikBug's IoC Container: LogikBug's IoC Container v 1.1: In this release, I add the ability to extend the container using the LogikBug.Injection.Extensibility namespace.MediaCoder.NET: MediaCoder.NET v1.0 beta Source Code: Source code for MediaCoder.NET v1.0 beta it includes everything - also the installer.Memetic NPC Behavior Toolkit: Wandering Meme Test: This was a code spike to see the first custom meme in action. The first meme chosen was the "Wander" meme. This is a Visual Studio 2010 solution. ...Microsoft Silverlight Media Framework: Silverlight Media Framework v2 (RC1): This is the first release candidate for the Microsoft Silverlight Media Framework v2. Note: The IIS Smooth Streaming Player Development Kit assem...mwNSPECT: mwNSPECT Beta: mwNSPECT Mapwindow plugin dll. Place in your MapWindow or BASINS plugins directory. Presently for testing everything, though very much known issu...mwNSPECT: mwNSPECT Beta Installer: Simplistic mwNSPECT Mapwindow plugin installer using Inno setup. Installs all the files you'll need for NSPECT into the C:\NSPECT folder and insta...Near forums - ASP.NET MVC forum engine: Release 1: First release of the SEO friendly ASP.NET MVC forum engine.NLog - Advanced .NET Logging: Nightly Build 2010.06.07.001: Changes since the last build:2010-06-06 22:13:02 Jarek Kowalski Added unit tests for common target behaviors. 2010-06-06 19:36:44 Jarek Kowalski c...patterns & practices – Enterprise Library: Enterprise Library 5.0 - Dev Guide (RC): This is a Release Candidate of the Developer's Guide, C# EditionPSAdmin: 1.0.0.0: This is an alpha release of PSAdmin and should be tested before putting into a production environment. This package is pre-compiled and ready for ...Refix - .NET dependency management: Refix v0.1.0.59 ALPHA: Still a very early version. Functional changes: Added new pre (prebuild) and fix commands (rfx help pre and rfx help fix for explanations).SCSM Service Request: Service Request Management Pack v0.1: !This is an ALPHA release. Please use for testing purposes only.! The management pack is not sealed which means that when a new version of the Se...SFTP Component for .NET CSharp, VB.NET, and ASP.NET: SFTP WinForms Client: SFTP WinForms ClientSharePoint Feature - Version history list Export to Excel: Export Item List Version 1.1: - allows you to select columns to export - multilanguage support Czech, English - some bug fix Install: "C:\Program Files\Common Files\Microsoft S...SharePoint Outlook Connector: Source Code for Version 1.2.4.3: Source Code for Version 1.2.4.3SharePoint PowerRSS: v1.0: Easy/Clean way to get SharePoint list data via more standard RSS feed. I found CleanRSS.aspx as part of SPRSS: Enhanced RSS Functionality for WSS ...Smith Async .NET Memcached Client: Smith.Amc 0.7.3810.36347: Smith Async Memcached client release 0.7.3810.36347 available First public release available. All memcached operations has been implemented except...Star Trooper for XNA 2D Tutorial: Lesson five content: Here is Lesson five original content for the StarTrooper 2D XNA tutorial. The blog tutorial has now started over on http://xna-uk.net/blogs/darkge...Star Trooper for XNA 2D Tutorial: Lesson six content: Here is Lesson six original content for the StarTrooper 2D XNA tutorial. The blog tutorial has now started over on http://xna-uk.net/blogs/darkgen...Stripper: Stripper.exe version 0.1.0: Stripper Remove Diacritics and other unwanted caracters to fabric a more standardized file naming. Especially French caracter and maybe other lang...SystemCentered Operations Manager Reporting: SystemCentered Reports V1: Reports Windows Computer General Performance When troubleshooting performance problems there are typically a set of "go to" performance counters t...TFS Buddy: TFS Buddy Beta 1.1: Minor changes +Added repeat function in action tab to simplyfy creating actions +Added app manifest to make the exe require run as Admin ~How the I...Thumbnail creator and image resizer: ThumbnailCreator1.2.1: ThumbnailCreator1.2.1 added importing of namespaces to .vb(previously in web.config)TokyoTyrantClient: TokyoTyrantClient release: 该客户端有如下特点: 1.支持TcpClient连接池 2.支持UTF-8编码 3.支持初始化链接数,链接过期时间,最大空闲时间,最长工作时间等设置。Ultimate FTP Component for .NET C#, VB.NET and ASP.NET: Build 519: New Release Download setup package at: http://www.componentsoft.net/component/download/?name=UltimateFtp Product Home Page: http://www.componentsof...visinia: visinia_1.2: The new stable version of visinia cms is out, it is visinia 1.2. It has many new features like the admin is one more time is given a new look. the ...WCF 4 Templates for Visual Studio 2010: AnonymousOverHttp: This template generates a WCF service application that exposes a BasicHttpBinding endpoint with maxed message size and reader quotas to provide an ...WhiteMoon: WhiteMoon 0.2.10 Source: The Source code of WhiteMoon 0.2 build 10Most Popular ProjectsCommunity Forums NNTP bridgeASP.NET MVC Time PlannerMoonyDesk (windows desktop widgets)NeatUploadOutSyncViperWorks IgnitionAgUnit - Silverlight unit testing with ReSharperSmith Async .NET Memcached ClientASP.NET MVC ExtensionsAviva Solutions C# Coding GuidelinesMost Active ProjectsCommunity Forums NNTP bridgepatterns & practices – Enterprise LibraryRawrjQuery Library for SharePoint Web ServicesNB_Store - Free DotNetNuke Ecommerce Catalog ModuleGMap.NET - Great Maps for Windows Forms & PresentationN2 CMSStyleCopsmark C# LibraryBlogEngine.NET

    Read the article

  • Max TCP Connections to a machine

    - by A9S6
    I am creating a Windows Service in .NET to which N number of client can connect. The service starts a TCP listener and accepts the client connections. The problem I am facing is that I can only open 10 connections to this service. The listener::AcceptTcpClient() method accepts only 10 connection and throws an exception for 11th one. The client application uses the System.Net.Sockets.TcpClient class and the service is using System.Net.Sockets.TcpListener class. This is the exception that I am getting when I try to make a number of connections in a for loop to this service (after the 10th connection is made): "Unable to read data from Transport connection: An exsting connection was forcibly closed by remote host"

    Read the article

  • C#: How to set AsyncWaitHandle in Compact Framework?

    - by Thorsten Dittmar
    Hi, I'm using a TcpClient in one of my Compact Framework 2.0 applications. I want to receive some information from a TCP server. As the Compact Framework does not support the timeout mechanisms of the "large" framework, I'm trying to implement my own timeout-thing. Basically, I want to do the following: IAsyncResult result = client.BeginRead(buffer, 0, size, ..., stream); if (!result.AsyncWaitHandle.WaitOne(5000, false)) // Handle timeout private void ReceiveFinished(IAsyncResult ar) { NetworkStream stream = (NetworkStream)ar.AsyncState; int numBytes = stream.EndRead(ar); // SIGNAL IASYNCRESULT.ASYNCWAITHANDLE HERE ... HOW?? } I'd like to call Set for the IAsyncResult.AsyncWaitHandle, but it doesn't have such a method and I don't know which implementation to cast it to. How do I set the wait handle? Or is it automatically set by calling EndRead? The documentation suggests that I'd have to call Set myself... Thanks for any help!

    Read the article

  • Asyncronously receiving data in an ASP.NET MVC application

    - by Mitciv
    I'm looking for the best way to constantly check if data has been sent to our ASP.NET MVC application from a server. I would like to asynchronously check for data and update the view when data has been read. I'm currently using a TcpClient to make a connection, and making the connection in the inherited custom base controller. Currently though I have to refresh the page for the updating of the view to take place. Would there be a proper AJAX solution? or do I need to move the connection to the ActionMethod?

    Read the article

  • Unable to make 2 parallel TCP requests to the same TCP Client

    - by soldieraman
    Error: Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall Situation There is a TCP Server My web application connects to this TCP Server Using the below code: TcpClientInfo = new TcpClient(); _result = TcpClientInfo.BeginConnect(<serverAddress>,<portNumber>, null, null); bool success = _result.AsyncWaitHandle.WaitOne(20000, true); if (!success) { TcpClientInfo.Close(); throw new Exception("Connection Timeout: Failed to establish connection."); } NetworkStreamInfo = TcpClientInfo.GetStream(); NetworkStreamInfo.ReadTimeout = 20000; 2 Users use the same application from two different location to access information from this server at the SAME TIME Server takes around 2sec to reply Both Connect But One of the user gets above error "Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall" when trying to read data from stream How can I resolve this issue? Use a better way of connecting to the server Can't because it's a server issue if a server issue, how should the server handle request to avoid this problem

    Read the article

  • android call an outside function from a thread

    - by junmats
    hi.. say for example I have this code in my activity: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Thread cThread = new Thread(new Runner()); cThread.start(); } private NotifyMe(){ //do something here } and this is my Runner class: public class TCPClient implements Runnable { public void run(){ //call NotifyMe() [THIS IS MY QUESTION] } } I have a thread on my activity that runs the Runner Class. Once the thread start, I would like to call the NotifyMe() function that is located at the activity. Is this possible? Please let me know if you don't understand my question. Thanks in advance.

    Read the article

  • How can I safely raise events in an AsyncCallback?

    - by cyclotis04
    I'm writing a wrapper class around a TcpClient which raises an event when data arrives. I'm using BeginRead and EndRead, but when the parent form handles the event, it's not running on the UI thread. I do I need to use delegates and pass the context into the callback? I thought that callbacks were a way to avoid this... void ReadCallback(IAsyncResult ar) { int length = _tcpClient.GetStream().EndRead(ar); _stringBuilder.Append(ByteArrayToString(_buffer, length)); BeginRead(); OnStringArrival(EventArgs.Empty); }

    Read the article

  • SOCKET chat C# with private messaging

    - by Sergei
    I want to create SOCKET chat(server + clients) with private messaging. When client write smth to stream, he should notify server that it is private message for user X, how can i do this? Actually i can do smth like this: string command = "PRIV|" + txtMessage.Text; swSender.WriteLine(command); but i think it isn't good, for example if user wants send message like our "PRIV|" flag it will be errors public class TestChat { private StreamWriter swSender; private IPAddress ipAddr; private void InitializeandSend() { //ip from text box ipAddr = IPAddress.Parse(txtIp.Text); // Start a new TCP connections to the chat server tcpServer = new TcpClient(); tcpServer.Connect(ipAddr, 1986); //... //sending message from text box swSender.WriteLine(txtMessage.Text); swSender.Flush(); } }

    Read the article

  • How to know when the Client is disconnected from Server in C#?

    - by menacheb
    Hi, I have a Client-Server program in C#. Here is the Server's code: ... String dataFromClient = ""; NetworkStream networkStream; TcpClient clientSocket; bool transfer = true; ... while (transfer) { networkStream = clientSocket.GetStream(); networkStream.Read(bytesFrom, 0, (int)clientSocket.ReceiveBufferSize); dataFromClient = System.Text.Encoding.ASCII.GetString(bytesFrom); dataFromClient = dataFromClient.Substring(0, dataFromClient.IndexOf("$")); .... } I want to make a condition that stop the loop when the Client is disconnected. How can I do that? Many thanks,

    Read the article

  • TCP/IP and UDP Questions and very small application for interview

    - by Shantanu Gupta
    I am going for an interview day after tomorrow where i will be asked vaious questions related to TCP/IP and UDP. As of now i have prepared theoritical knowledge about it. But now I am looking up for gaining some practicle knowledge related to how it works in a network. What all is going in vaious .NET classes. I want to create a very small application like a chat or something that can make me all these concepts very much clear. Could you please suggest some questions related to TCP/IP that you generally ask or that you might have faced. How communication is going from server to client. Right now I am studying TcpClient, TcpListener and UdpClient Class but I want to implement all of them so as to get aware about its working. Is Chat application a Tcp/IP application ? I would appreciate your help.

    Read the article

  • Interview Questions that can be asked on TCP/IP, UDP, Socket Programming ?

    - by Shantanu Gupta
    I am going for an interview day after tomorrow where i will be asked vaious questions related to TCP/IP and UDP. As of now i have prepared theoritical knowledge about it. But now I am looking up for gaining some practicle knowledge related to how it works in a network. What all is going in vaious .NET classes. I want to create a very small application like a chat or something that can make me all these concepts very much clear. Could you please suggest some questions related to TCP/IP that you generally ask or that you might have faced. How communication is going from server to client. Right now I am studying TcpClient, TcpListener and UdpClient Class but I want to implement all of them so as to get aware about its working. Is Chat application a Tcp/IP application ? I would appreciate your help.

    Read the article

  • Code generation tool, to create C# adapter classes for unit testing?

    - by RyBolt
    I know I wouldn't need this with Typemock, however, with something like MoQ , I need to use the adapter pattern to enable the creation of mocks via interfaces for code I don't control. For example, TcpClient is a .NET class, so I use adapter pattern to enable mocking of this object, b/c I need an interface of that class. I then produce interface ITcpClient, that can then be implemented via a TcpClientAdapter class, which is just plain vanilla adapter pattern implementation. I am looking for a tool to do this automatically (creation of interface and adapter), I would think there is one out there somewhere? (or is everyone just hand coding these)

    Read the article

  • How can i learn file name and create a folder?

    - by Phsika
    i try to make TCP/Ip Application to listen any other roemote computer to recieve any file. So i try to get files. i can do that. on the other hand every sample on google about giving SaveDialogBox to recived path folder.Forexample my old server.cs is that: 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; using System.Threading; namespace Server3 { public partial class Form1 : Form { Thread kanal; public Form1() { InitializeComponent(); try { kanal = new Thread(new ThreadStart(Dinle)); kanal.Start(); kanal.Priority = ThreadPriority.Normal; this.Text = "Kanal Çalisti"; } catch (Exception ex) { this.Text = "kanal çalismadi"; MessageBox.Show("hata:" + ex.ToString()); kanal.Abort(); throw; } } void Dinle() { TcpListener server = null; try { Int32 port = 51124; IPAddress localAddr = IPAddress.Parse("127.0.0.1"); server = new TcpListener(localAddr, port); server.Start(); Byte[] bytes = new Byte[1024 * 250000]; // string ReceivedPath = "C:/recieved"; while (true) { MessageBox.Show("Waiting for a connection... "); TcpClient client = server.AcceptTcpClient(); MessageBox.Show("Connected!"); NetworkStream stream = client.GetStream(); if (stream.CanRead) { saveFileDialog1.ShowDialog(); string pathfolder = saveFileDialog1.FileName; StreamWriter yaz = new StreamWriter(pathfolder); string satir; StreamReader oku = new StreamReader(stream); while ((satir = oku.ReadLine()) != null) { satir = satir + (char)13 + (char)10; yaz.WriteLine(satir); } oku.Close(); yaz.Close(); client.Close(); } } } catch (SocketException e) { Console.WriteLine("SocketException: {0}", e); } finally { // Stop listening for new clients. server.Stop(); } Console.WriteLine("\nHit enter to continue..."); Console.Read(); } private void Form1_Load(object sender, EventArgs e) { Dinle(); } } } i want to give automatically folder without SAVEDIALOGBOX. Also i want to learn my file name om my stream.Like that: 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; using System.Threading; namespace Server3 { public partial class Form1 : Form { Thread kanal; public Form1() { InitializeComponent(); try { kanal = new Thread(new ThreadStart(Dinle)); kanal.Start(); kanal.Priority = ThreadPriority.Normal; this.Text = "Kanal Çalisti"; } catch (Exception ex) { this.Text = "kanal çalismadi"; MessageBox.Show("hata:" + ex.ToString()); kanal.Abort(); throw; } } void Dinle() { TcpListener server = null; try { Int32 port = 51124; IPAddress localAddr = IPAddress.Parse("127.0.0.1"); server = new TcpListener(localAddr, port); server.Start(); Byte[] bytes = new Byte[1024 * 250000]; string ReceivedPath = "C:/recieved"; while (true) { MessageBox.Show("Waiting for a connection... "); TcpClient client = server.AcceptTcpClient(); MessageBox.Show("Connected!"); NetworkStream stream = client.GetStream(); if (stream.CanRead) { saveFileDialog1.ShowDialog(); string pathfolder = " i have to give property creating path and want to learn file name"; StreamWriter yaz = new StreamWriter(pathfolder); string satir; StreamReader oku = new StreamReader(stream); while ((satir = oku.ReadLine()) != null) { satir = satir + (char)13 + (char)10; yaz.WriteLine(satir); } oku.Close(); yaz.Close(); client.Close(); } } } catch (SocketException e) { Console.WriteLine("SocketException: {0}", e); } finally { // Stop listening for new clients. server.Stop(); } Console.WriteLine("\nHit enter to continue..."); Console.Read(); } private void Form1_Load(object sender, EventArgs e) { Dinle(); } } } Also i need : FileStream fs; FileInfo fi = new FileInfo(@"c:/recieved"); if (fi.Exists) fs = new FileStream(fi.FullName, FileMode.Append); else fs = new FileStream(fi.FullName, FileMode.Create); StreamWriter yazici = new StreamWriter(fs); How can i do that. Creating C:/recieved if it does not exist. And how can i learn File name on my network stream sending File Name.

    Read the article

  • Review: A Quick Look at Reflector

    - by James Michael Hare
    I, like many, was disappointed when I heard that Reflector 7 was not free, and perhaps that’s why I waited so long to try it and just kept using my version 6 (which continues to be free).  But though I resisted for so long, I longed for the better features that were being developed, and began to wonder if I should upgrade.  Thus, I began to look into the features being offered in Reflector 7.5 to see what was new. Multiple Editions Reflector 7.5 comes in three flavors, each building on the features of the previous version: Standard – Contains just the Standalone application ($70) VS – Same as Standard but adds Reflector Object Browser for Visual Studio ($130) VSPro – Same as VS but adds ability to set breakpoints and step into decompiled code ($190) So let’s examine each of these features. The Standalone Application (Standard, VS, VSPro editions) Popping open Reflector 7.5 and looking at the GUI, we see much of the same familiar features, with a few new ones as well: Most notably, the disassembler window now has a tabbed window with navigation buttons.  This makes it much easier to back out of a deep-dive into many layers of decompiled code back to a previous point. Also, there is now an analyzer which can be used to determine dependencies for a given method, property, type, etc. For example, if we select System.Net.Sockets.TcpClient and hit the Analyze button, we’d see a window with the following nodes we could expand: This gives us the ability to see what a given type uses, what uses it, who exposes it, and who instantiates it. Now obviously, for low-level types (like DateTime) this list would be enormous, but this can give a lot of information on how a given type is connected to the larger code ecosystem. One of the other things I like about using Reflector 7.5 is that it does a much better job of displaying iterator blocks than Reflector 6 did. For example, if you were to take a look at the Enumerable.Cast() extension method in System.Linq, and dive into the CastIterator in Reflector 6, you’d see this: But now, in Reflector 7.5, we see the iterator logic much more clearly: This is a big improvement in the quality of their code disassembler and for me was one of the main reasons I decided to take the plunge and get version 7.5. The Reflector Object Browser (VS, VSPro editions) If you have the .NET Reflector VS or VSPro editions, you’ll find you have in Visual Studio a Reflector Object Browser window available where you can select and decompile any assembly right in Visual Studio. For example, if you want to take a peek at how System.Collections.Generic.List<T> works, you can either select List<T> in the Reflector Object Browser, or even simpler just select a usage of it in your code and CTRL + Click to dive in. – And it takes you right to a source window with the decompiled source: Setting Breakpoints and Stepping Into Decompiled Code (VSPro) If you have the VSPro edition, in addition to all the things said above, you also get the additional ability to set breakpoints in this decompiled code and step through it as if it were your own code: This can be a handy feature when you need to see why your code’s use of a BCL or other third-party library isn’t working as you expect. Summary Yes, Reflector is no longer free, and yes, that’s a bit of a bummer. But it always was and still is a very fine tool. If you still have Reflector 6, you aren’t forced to upgrade any longer, but getting the nicer disassembler (especially for iterator blocks) and the handy VS integration is worth at least considering upgrading for.  So I leave it up to you, these are some of the features of Reflector 7.5, what’s your thoughts? Technorati Tags: .NET,Reflector

    Read the article

  • C# StreamReader.EndOfStream produces IOException

    - by Ziplin
    I'm working on an application that accepts TCP connections and reads in data until an </File> marker is read and then writes that data to the filesystem. I don't want to disconnect, I want to let the client sending the data to do that so they can send multiple files in one connection. I'm using the StreamReader.EndOfStream around my outter loop, but it throws an IOException when the client disconnects. Is there a better way to do this? private static void RecieveAsyncStream(IAsyncResult ar) { TcpListener listener = (TcpListener)ar.AsyncState; TcpClient client = listener.EndAcceptTcpClient(ar); // init the streams NetworkStream netStream = client.GetStream(); StreamReader streamReader = new StreamReader(netStream); StreamWriter streamWriter = new StreamWriter(netStream); while (!streamReader.EndOfStream) // throws IOException { string file= ""; while (file!= "</File>" && !streamReader.EndOfStream) { file += streamReader.ReadLine(); } // write file to filesystem } listener.BeginAcceptTcpClient(RecieveAsyncStream, listener); }

    Read the article

  • F# Async problem.

    - by chrisdew
    Hi, I've written a dummy http server as an exercise in F#. I'm using Mono 2.4.4 on Ubuntu 10.04 x86_64, with MonoDevelop. The following code fails to compile with the error: Error FS0039: The field, constructor or member 'Spawn' is not defined (FS0039) Could someone try this in VisualStudio please, I don't know whether this is a Mono problem, or my problem. I have tried several Async examples from the F# book, and they also all produce similar messages about Async.* methods. Thanks, Chris. #light open System open System.IO open System.Threading open System.Net open System.Net.Sockets open Microsoft.FSharp.Control.CommonExtensions printfn "%s" "Hello World!" let headers = System.Text.Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: 37\r\nDate: Sun, 13 Jun 2010 05:30:00 GMT\r\nServer: FSC/0.0.1\r\n\r\n") let content = System.Text.Encoding.ASCII.GetBytes("<html><body>Hello World</body></html>") let serveAsync (client : TcpClient) = async { let out = client.GetStream() do! out.AsyncWrite(headers) do! Async.Sleep 3000 do! out.AsyncWrite(content) do out.Close() } let http_server (ip, port) = let server = new TcpListener(IPAddress.Parse(ip),port) server.Start() while true do let client = server.AcceptTcpClient() printfn "new client" Async.Spawn (serveAsync client) http_server ("0.0.0.0", 1234)

    Read the article

  • .NET TCP socket with session

    - by Zé Carlos
    Is there any way of dealing with sessions with sockets in C#? Example of my problem: I have a server with a socket listening on port 5672. TcpListener socket = new TcpListener(localAddr, 5672); socket.Start(); Console.Write("Waiting for a connection... "); // Perform a blocking call to accept requests. TcpClient client = socket.AcceptTcpClient(); Console.WriteLine("Connected to client!"); And i have two clients that will send one byte. Client A send 0x1 and client B send 0x2. From the server side, i read this data like this: Byte[] bytes = new Byte[256]; String data = null; NetworkStream stream = client.GetStream(); while ((stream.Read(bytes, 0, bytes.Length)) != 0) { byte[] answer = new ... stream.Write(answer , 0, answer.Length); } Then client A sends 0x11. I need a way to know that this client is the same that sent "0x1" before.

    Read the article

  • How to File Transfer client to Server?

    - by Phsika
    i try to recieve a file from server but give me error on server.Start() ERROR : In a manner not permitted by the access permissions to access a socket was attempted to How can i solve it? private void btn_Recieve_Click(object sender, EventArgs e) { TcpListener server = null; // Set the TcpListener on port 13000. Int32 port = 13000; IPAddress localAddr = IPAddress.Parse("192.168.1.201"); // TcpListener server = new TcpListener(port); server = new TcpListener(localAddr, port); // Start listening for client requests. server.Start(); // Buffer for reading data Byte[] bytes = new Byte[277577]; String data; data = null; // Perform a blocking call to accept requests. // You could also user server.AcceptSocket() here. TcpClient client = server.AcceptTcpClient(); NetworkStream stream = client.GetStream(); int i; i = stream.Read(bytes, 0, 277577); BinaryWriter writer = new BinaryWriter(File.Open("GoodLuckToMe.jpg", FileMode.Create)); writer.Write(bytes); writer.Close(); client.Close(); }

    Read the article

  • StreamReader.EndOfStream produces IOException

    - by Ziplin
    I'm working on an application that accepts TCP connections and reads in data until an </File> marker is read and then writes that data to the filesystem. I don't want to disconnect, I want to let the client sending the data to do that so they can send multiple files in one connection. I'm using the StreamReader.EndOfStream around my outter loop, but it throws an IOException when the client disconnects. Is there a better way to do this? private static void RecieveAsyncStream(IAsyncResult ar) { TcpListener listener = (TcpListener)ar.AsyncState; TcpClient client = listener.EndAcceptTcpClient(ar); // init the streams NetworkStream netStream = client.GetStream(); StreamReader streamReader = new StreamReader(netStream); StreamWriter streamWriter = new StreamWriter(netStream); while (!streamReader.EndOfStream) // throws IOException { string file= ""; while (file!= "</File>" && !streamReader.EndOfStream) { file += streamReader.ReadLine(); } // write file to filesystem } listener.BeginAcceptTcpClient(RecieveAsyncStream, listener); }

    Read the article

  • C# TCP socket with session

    - by Zé Carlos
    Is there any way of dealing with sessions with sockets in C#? Example of my problem: I have a server with a socket listening on port 5672. TcpListener socket = new TcpListener(localAddr, 5672); socket.Start(); Console.Write("Waiting for a connection... "); // Perform a blocking call to accept requests. TcpClient client = socket.AcceptTcpClient(); Console.WriteLine("Connected to client!"); And i have two clients that will send one byte. Client A send 0x1 and client B send 0x2. From the server side, i read this data like this: Byte[] bytes = new Byte[256]; String data = null; NetworkStream stream = client.GetStream(); while ((stream.Read(bytes, 0, bytes.Length)) != 0) { byte[] answer = new ... stream.Write(answer , 0, answer.Length); } Then client A sends 0x11. I need a way to know that this client is the same that sent "0x1" before.

    Read the article

  • Sending jpegs by tcp socket...sometimes incomplete.

    - by Guy
    Vb.net Hi I've been working on a project for months now (vb 2008 express). There is one final problem which I can't solve. I need to send images to a client from a 'server'(listener). The code below works most of the time but sometimes the image is incomplete. I believe this might be something to do with the tcp packet sizes varying, maybe limited by how busy it is out there on the net. I have seen examples of code that splits the image into chunks and sends them out, but I can't get them to work maybe because I'm using a different vb version. The pictures to be sent are small 20k max. Any working code examples would be wonderful. I have been experimenting and failing with this final hurdle for weeks. Thanks in anticipation. Client----- Sub GetPic() '------- Connect to Server ClientSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, _ ProtocolType.Tcp) ClientSocket.Connect(Epoint) '------- Send Picture Request Dim Bytes() As Byte = System.Text.ASCIIEncoding.ASCII.GetBytes("Send Picture") ClientSocket.Send(Bytes, Bytes.Length, SocketFlags.None) '------- Receive Response Dim RecvBuffer(20000) As Byte Dim Numbytes As Integer Numbytes = ClientSocket.Receive(RecvBuffer) Dim Darray(Numbytes) As Byte Buffer.BlockCopy(RecvBuffer, 0, Darray, 0, Numbytes) '------- Close Connection ClientSocket.Shutdown(SocketShutdown.Both) ClientSocket.Close() '------- Dim MStrm = New MemoryStream(Darray) Picture = Image.FromStream(MStrm) End Sub Listener----- 'Threaded from a listener Sub ClientThread(ByVal Client As TcpClient) Dim MStrm As New MemoryStream Dim Rbuffer(1024) As Byte Dim Tbyte As Byte() Dim NStrm As NetworkStream = Client.GetStream() Dim I As Integer = NStrm.Read(Rbuffer, 0, Rbuffer.Length) Dim Incoming As String = System.Text.Encoding.ASCII.GetString(Rbuffer, 0, I) If Incoming = "Send Picture" then Picture Save(MStrm, Picture.RawFormat) Tbyte = MStrm.ToArray NStrm.Write(Tbyte, 0, Tbyte.Length) End if Client.Close() End Sub

    Read the article

  • deserialize system.outofmemoryexception

    - by clanier9
    I've got a serializeable class called Cereal with several public fields shown here <Serializable> Public Class Cereal Public id As Integer Public cardType As Type Public attacker As String Public defender As String Public placedOn As String Public attack As Boolean Public placed As Boolean Public played As Boolean Public text As String Public Sub New() End Sub End Class My client computer is sending a new Cereal to the host by serializing it shown here 'sends data to host stream (c1) Private Sub cSendText(ByVal Data As String) Dim bf As New BinaryFormatter Dim c As New Cereal c.text = Data bf.Serialize(mobjClient.GetStream, c) End Sub The host listens to the stream for activity and when something gets put on it, it is supposed to deserialize it to a new Cereal shown here 'accepts data sent from the client, raised when data on host stream (c2) Private Sub DoReceive(ByVal ar As IAsyncResult) Dim intCount As Integer Try 'find how many byte is data SyncLock mobjClient.GetStream intCount = mobjClient.GetStream.EndRead(ar) End SyncLock 'if none, we are disconnected If intCount < 1 Then RaiseEvent Disconnected(Me) Exit Sub End If Dim bf As New BinaryFormatter Dim c As New Cereal c = CType(bf.Deserialize(mobjClient.GetStream), Cereal) If c.text.Length > 0 Then RaiseEvent LineReceived(Me, c.text) Else RaiseEvent CardReceived(Me, c) End If 'starts listening for action on stream again SyncLock mobjClient.GetStream mobjClient.GetStream.BeginRead(arData, 0, 1024, AddressOf DoReceive, Nothing) End SyncLock Catch e As Exception RaiseEvent Disconnected(Me) End Try End Sub when the following line executes, I get a System.OutOfMemoryException and I cannot figure out why this isn't working. c = CType(bf.Deserialize(mobjClient.GetStream), Cereal) The stream is a TCPClient stream. I'm new to serialization/deserialization and using visual studio 11

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >