![]() ![]() So, instead of providing the ConnectionCompleted, MessageReceived and MessageSent-events, you will always receive the Completed-event which you must know how to handle. The SocketAsyncEventArgs-instance will always raise a Completed-event when the operation has been executed. When you execute an operation with the Socket-class, you’ll have to provide the SocketAsyncEventArgs-instance for it as a parameter. And even though the class has the “EventArgs”-postfix, it is up to you to create the instances of this class. Instead we have to always rely on the SocketAsyncEventArgs-class to provide us the information we want. Where the socket-class comes short is providing any information on the events that happen with our connection. So you execute your work through the socket-class but you receive the feedback through a different route: With the help of the SocketAsyncEventArgs-class. What makes it little complicated is that it doesn’t provide any feedback by itself if these operations succeeded or not. The socket-class offers the basic operations like ConnectAsync, SendAsync and ReceiveAsync. ![]() So we create the instance, connect to the server using the ConnectAsync-methodand then keep the socket-instance available for further work. In our case we want to create the connection and keep it open. This instance will define the key aspects of the connection, like the selection between the TCP and the UDP-protocols. The Socket-classĪn instance of the socket-class represents our connection to the server. But when we start creating our application, we will cover most of the other interesting classes in the namespace. We will focus only in these two classes because they are the central piece when creating our demo-application, the IRC-client. And in this case “differently” means that instead of coming up with a new meaning for events and event arguments, it could have stick to the guidance. But from what I’ve personally seen and experienced with the classes, the whole sockets-support could have been designed differently. Maybe I just haven’t had the need to use those aspects of the socket-support which have forced to make the classes inside the namespace work strangely. Maybe the fact that it deals with sockets has made the whole namespace to bend the rules. Sometimes I’ve wondered how one namespace can be so different from the others. Unfortunately the namespace is an odd bird when it comes to naming conventions and usability. Understanding these two classes is the key to understanding the sockets-support. The namespaceĪll the required components for creating a successful TCP-connection live inside the –namespace.The namespace contains over 25 classes and enumerations but from those 25 only two classesstand out as an integral piece of the sockets-support: The Socket-class and the SocketAsyncEventArgs-class. So the Mango devices can connect to any IP address and to any port they want, as long as it’s open. WP7 Mango supports both the TCP and UDP protocols and to the delight of many people, its port-range hasn’t been restricted. The Mango-update for Windows Phone 7 is arriving soon and one of the new features is the added support for sockets. In this first post we will investigate on how one can create and open a TCP-connection to a server. If you want to better understand the inner details of the Internet sockets, Wikipedia has a good introduction on the subject. The focus of these posts is in the WP7’s developer’s perspective. In these posts we will go through of building a complete IRC-client. This tutorial series will focus on developing WP7 applications which require a long running TCP-connection that send and receive text-based data. Learn more at This is the part I of a tutorial series which will describe the WP7’s sockets-support from a developer’s perspective. Advert: IRC7 is theIRC-client for Windows Phone 7. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |