Skip to main content

Posts

Showing posts from July, 2008

XMPP

eXtensible Messaging and Presence Protocol (XMPP) is a protocol to stream XML elements for messaging, presence and request-response services. It is mainly used in building IM and presence based applications. The protocol is not coupled to any network architecture, but it’s generally used in client-server architecture. An XMPP server can communicate with its clients (recommended port: 5222) or with other XMPP servers (recommended port: 5269) over a TCP connection. An example network architecture could be like The gateway is necessary to translate the messages between a non-XMPP server and an XMPP server. All XMPP messaging happens in the form of Streams and Stanzas. Stream is the container for all messages sent from one entity to the other. A stream is initiated with a < stream > tag and is destroyed with a < / stream > tag. Multiple XML elements can be sent over the connection before the stream is closed. These streams are unidirectional i.e. if a client initiates a stream

LINQ - Introduction

LINQ (Language Integrated Query) introduces a generic and standard pattern for querying and updating data store of any kind. Basically a query is an expression that retrieves data from a data source. Queries are usually expressed in a specialized query language. I assume LINQ is intoduced to decouple the query language from the datasource. This avoids a lot of "unnecessary" learnings, because literally there is query language for each type of data source be it SQL databases, ADO.NET datasets, Collections types and XML documents. A LINQ query operations has there distinct phases:   Recognizing the Data Source With LINQ, there is another concept that has been introduced called Queryable, implementing interface IQueryable. Any Enumerable type is a queryable type and it requires no modification as a LINQ data source. If the source data is not already in memory as a queryable type, the LINQ provider must represent it as such. For example, LINQ to XML loads an XML document into a q

Marshalling Array of Structures

It is fairly easy to Marshal simple structures in .NET but when it comes to sending a whole bunch of structures as parameter it’s little head scratching task if you have not done it already. The worst part is you won’t find any articles on how one should go about it. When I had to marshal an array of structures, every time I ran into same state of confusion. I decided to blog it this time (for future reference of course :) ) So let’s assume there is a structure called StructType and structArray be an array of StructType . //Lets not bother about how the array was populated StructType [] structArray = new GetStructArray(); // Get the size of each element int structSize = Marshal .SizeOf(structArray [0]); Here int can be replaced with long (depends on 32 bit or 64 bit addressing) // Total size of the memory block IntPtr ptr = Marshal .AllocHGlobal(structSize * structArray.Length); int addr = ( int )ptr; for ( int index = 0; index < structArray.Length; index++)