tag:blogger.com,1999:blog-41936837921732146662024-03-10T14:19:02.155+05:30Advanced Computer Programming Learn step by step network programming using C#.Net socket, remoting, WCF and SignalR technology from lots of source code and description. All source code download link available at end of the blog post.Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.comBlogger46125tag:blogger.com,1999:blog-4193683792173214666.post-75961211681911068312016-05-05T22:50:00.003+05:302017-01-12T23:05:11.512+05:30How to include Web Fonts in my website<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "verdana" , sans-serif;"><b>Problem:</b></span><br />
<span style="font-family: "verdana" , sans-serif;">I need to include specific font (</span><span style="font-family: "verdana" , sans-serif;">Futura Bold</span><span style="font-family: "verdana" , sans-serif;"> for my case)</span><span style="font-family: "verdana" , sans-serif;"> in my website but it is not supporting it, whenever I am trying to include it is not reflecting in browser. I double check my HTML and CSS syntax, everything fine but still there has no effect. What is the problem?</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><b>Web font what it is?</b></span><br />
<span style="font-family: "verdana" , sans-serif;">I am facing the problem just because of the desire font is not standard web fonts hence it is not getting effect. Solution is convert font as web standard and include in project, after that I can use it. Next problem, How?</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><b>How to generated any font as web standard font (webfonts)?</b></span><br />
<span style="font-family: "verdana" , sans-serif;">Conversion font to webstandard is very easy if you know it. However its not difficult. </span><br />
<span style="font-family: "verdana" , sans-serif;">There has multiple website to generate webfonts. I have used <span style="color: blue;">https://www.fontsquirrel.com/tools/webfont-generator</span> to generate webfonts. This is very easy process, just upload the font and generate it. If the font is not available to you you can download it from website. I have downloaded Futura font from <span style="color: blue;">http://www.futurafontfree.com/fonts/futura-book-font-free-download</span>.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH2WfhyJhLd2wKCZPTea_x1eLqcgWh48RbotB9Ub5cGNTY8x7Ru3hInYGaFZQASS89wloYxEoELOiLHbfAoAFtsDF20izfywVDKhv3PrWTVv8pVF4F5OUeGOc4O3pwECv4jV4XuP8TxN4/s1600/webfont-generator.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH2WfhyJhLd2wKCZPTea_x1eLqcgWh48RbotB9Ub5cGNTY8x7Ru3hInYGaFZQASS89wloYxEoELOiLHbfAoAFtsDF20izfywVDKhv3PrWTVv8pVF4F5OUeGOc4O3pwECv4jV4XuP8TxN4/s400/webfont-generator.jpg" width="400" /></a></div>
<span style="font-family: "verdana" , sans-serif;">The generated webfonts downloaded as zip and after unzip the folder looks like below.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUMwWAh7fug4Eg7uF4mbaFAl4ZLHs5qhDcRpKaFWtFhpd_BDiYj5Nj-o8BjhXw1XKg7-wDGVBf7L4_rE6vMG4XgEDpTD0qMGW7cVjYDpkwsn7-zGGHSocY6X2zTC4YiRpBPDQu_TcJjjY/s1600/webfonts+folder.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="191" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUMwWAh7fug4Eg7uF4mbaFAl4ZLHs5qhDcRpKaFWtFhpd_BDiYj5Nj-o8BjhXw1XKg7-wDGVBf7L4_rE6vMG4XgEDpTD0qMGW7cVjYDpkwsn7-zGGHSocY6X2zTC4YiRpBPDQu_TcJjjY/s400/webfonts+folder.jpg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;">Generated folder comes with multiple files including stylesheet.css file. All of these files I need and might need to edit stylesheet.css file. Initially the style sheet file code looks as </span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<br />
<blockquote class="tr_bq">
<span style="font-family: "verdana" , sans-serif;"><br /></span><span style="font-family: "verdana" , sans-serif;">@font-face {</span><span style="font-family: "verdana" , sans-serif;"> font-family: 'futura_urw_extra_boldregular';</span><span style="font-family: "verdana" , sans-serif;"> src: url('futurat_bold-webfont.eot');</span><span style="font-family: "verdana" , sans-serif;"> src: url('futurat_bold-webfont.eot?#iefix') format('embedded-opentype'),</span><span style="font-family: "verdana" , sans-serif;"> url('futurat_bold-webfont.woff2') format('woff2'),</span><span style="font-family: "verdana" , sans-serif;"> url('futurat_bold-webfont.woff') format('woff'),</span><span style="font-family: "verdana" , sans-serif;"> url('futurat_bold-webfont.ttf') format('truetype'),</span><span style="font-family: "verdana" , sans-serif;"> url('futurat_bold-webfont.svg#futura_urw_extra_boldregular') format('svg');</span><span style="font-family: "verdana" , sans-serif;"> font-weight: normal;</span><span style="font-family: "verdana" , sans-serif;"> font-style: normal;</span><span style="font-family: "verdana" , sans-serif;"><br /></span><span style="font-family: "verdana" , sans-serif;">}</span></blockquote>
<span style="font-family: "verdana" , sans-serif;"></span><br />
<span style="font-family: "verdana" , sans-serif;">Basically these code is referring to generated files. Keep it as it is.</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><b>Include generated webfonts in my project.</b></span><br />
<span style="font-family: "verdana" , sans-serif;">Add the folder with all files in my project and next need need to add reference. My complete project is looks like </span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvlZ1e_N8P8aWGG6BKD9ZAAMZswsWYOfsEsVZRvOrcka7F7vpdkibtyYsB0fiqNNsAz0lGhoc22f4cFXm97kl2bQ56a6Pn2SkGEaG6Wv5hvr8F89bxBFk8n2sA5D3-slYU2yxY2Q1IE3A/s1600/webfonts+project.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvlZ1e_N8P8aWGG6BKD9ZAAMZswsWYOfsEsVZRvOrcka7F7vpdkibtyYsB0fiqNNsAz0lGhoc22f4cFXm97kl2bQ56a6Pn2SkGEaG6Wv5hvr8F89bxBFk8n2sA5D3-slYU2yxY2Q1IE3A/s400/webfonts+project.jpg" width="400" /></a></div>
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><b><br /></b></span>
<span style="font-family: "verdana" , sans-serif;">To include stylesheet in project is very common as we do always. Just add stylesheet by below code:</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="background-color: #fcfcfc; color: #282828; font-family: "andale mono" , "lucida console" , monospace; font-size: 12px; line-height: 18px;"><link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" /></span><br />
<span style="background-color: #fcfcfc; color: #282828; font-family: "andale mono" , "lucida console" , monospace; font-size: 12px; line-height: 18px;"><br /></span>
<span style="font-family: "verdana" , sans-serif;">Change font-family with new font in your code and its done, now run it from browser.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqasgMKKL_NYb0WMjIywdzFxr6dDcxduhkz1fsPM8Eqc83__uPcF0bxEluAtaXPFyWruh7nw1H5nCqoUPOa_lWkGhfUbVYxFIuOxYOXz373AJjKOZLd_7lqkCYckxzVDO474A9nDvTKU4/s1600/webfonts+in+browser.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="215" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqasgMKKL_NYb0WMjIywdzFxr6dDcxduhkz1fsPM8Eqc83__uPcF0bxEluAtaXPFyWruh7nw1H5nCqoUPOa_lWkGhfUbVYxFIuOxYOXz373AJjKOZLd_7lqkCYckxzVDO474A9nDvTKU4/s400/webfonts+in+browser.jpg" width="400" /></a></div>
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;">Download complete project from following URL.</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><a href="https://drive.google.com/file/d/0Bwd4GP6MNsEgN3BSdnI4Y3Zhak0/view?usp=sharing">https://drive.google.com/file/d/0Bwd4GP6MNsEgN3BSdnI4Y3Zhak0/view?usp=sharing</a> </span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><br /></span></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com4tag:blogger.com,1999:blog-4193683792173214666.post-41358762911899657772015-02-06T18:56:00.001+05:302015-04-05T19:48:40.502+05:30Real time multi person multi window chat application using SignalR<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="tr_bq" style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">This article is to demonstrate real time chat application using SignalR. I develop this code for my social network Alap.Me and it has tested with many people. This is super fast light weight and it can use many people at a time with multiple chat window. For alap.me due to window size I limit it to 4 active window. This looks as like gmail or facebook chat. My server was in UK and I tested it from India it's response time was around 0.350 second. That means when one person send message to some one, it deliver it in a popup within 0.350 second. I develop it as stand alone and later integrate it with alap.me. Similar way any one can use this ready-made code to his existing code. I am offering this as open source and any one can enhance this code by informing me (just a mail is ok) and its totally free of cost for non-profit purpose. </span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Prerequisite </b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">This has developed based on .Net 4.5 with Visual Studio 2013 express.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">I have setup it on Windows Server 2008.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">IIS version 7.5 (or higher).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">MySQL Database, however these has just 2 standard table you can create same in other database and can configure DB layer.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Technology Used</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">This is SignalR Hub based application with C# code.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">HTML5, CSS3 and JavaScript used for UI development.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">MySQL stored procedure with ADO.Net has used.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Code developed in Visual Studio 2013 Express for Web version used.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Basic Overview how it is working</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Describing later this section.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Source code</b></span><br />
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Below picture is showing my full code file list which I am going to share at below.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<blockquote class="tr_bq" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaq-09jQTSQFW8tdOrFj2uUf18xkC_jtt4MhaNu0DiCQXNUZe9h5wScvr08lplJPCHtqZ529fYkiCTbXRjve6JRdwkpFzpciZF0Kw_yHanCbDVxswDiPYBYUc2Vp6DAys-JOskfBjn1KM/s1600/SignalR-Chat+application.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaq-09jQTSQFW8tdOrFj2uUf18xkC_jtt4MhaNu0DiCQXNUZe9h5wScvr08lplJPCHtqZ529fYkiCTbXRjve6JRdwkpFzpciZF0Kw_yHanCbDVxswDiPYBYUc2Vp6DAys-JOskfBjn1KM/s1600/SignalR-Chat+application.jpg" height="320" width="200" /></a></blockquote>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
ChatHub.cs</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<blockquote style="clear: both;">
using System;<br />using System.Web;<br />using Microsoft.AspNet.SignalR;<br />using System.Data;<br />using System.Collections;<br />using System.Collections.Generic;<br />using System.Linq;<br />namespace SignalRChat<br />{<br /> public class ChatHub : Hub<br /> {<br /> AlapChat objChat;<br /> DataTable dt;<br /> static Hashtable htOnlineUsers = new Hashtable();<br /> static List<OnlineUser> OnlineUsers=new List<OnlineUser>();<br /> public ChatHub()<br /> {<br /> objChat = new AlapChat();<br /> }<br /> //public void Test(string str)<br /> //{<br /> // Clients.Caller.Hello(str + " | Message received at server reply from server." + DateTime.Now.ToShortTimeString());<br /> //}<br /> //public void Friends123()<br /> //{<br /> // dt = objChat.GetFriendLoginStatus("7");<br /> // string onlineUserList = UtilityChat.DataTableToJson(dt);<br /> // Clients.Caller.friendslist(onlineUserList);<br /> //}<br /> public void clean()<br /> {<br /> <br /> foreach (OnlineUser user in OnlineUsers)<br /> {<br /> objChat.SetOffline(user.MyId);<br /> }<br /> OnlineUsers.Clear();<br /> <br /> }<br /> public void Connect(string myid)<br /> {<br /> if(OnlineUsers.Count(x=>x.MyId==myid)==0)<br /> {<br /> OnlineUsers.Add(new OnlineUser { MyId = myid, ConnectionId = Context.ConnectionId });<br /> }<br /> }<br /> public void loginfriends(string myid,string name)<br /> {<br /> bool isOnline=false;<br /> if (OnlineUsers.Count(x => x.MyId == myid) == 0)<br /> {<br /> OnlineUsers.Add(new OnlineUser { MyId = myid, ConnectionId = Context.ConnectionId, Name = name });<br /> objChat.SetOnline(myid); <br /> } <br /> else //User found in Array, check if ConnectionId is same or not, if not replace it in Array<br /> {<br /> OnlineUser user = OnlineUsers.FirstOrDefault(x => x.MyId == myid);<br /> if(user.ConnectionId!=Context.ConnectionId)<br /> {<br /> // Clients.Caller.Hello("Remove and readd user.");<br /> OnlineUsers.Remove(user);//Delete existing and add new user<br /> OnlineUsers.Add(new OnlineUser { MyId = myid, ConnectionId = Context.ConnectionId, Name = name });<br /> }<br /> }<br /> dt = objChat.GetFriendLoginStatus(myid);<br /> foreach (DataRow dr in dt.Rows)<br /> {<br /> if (dr["IsOnline"].ToString().ToLower() == "true" || dr["IsOnline"].ToString() == "1")<br /> isOnline = true;<br /> else if (dr["IsOnline"].ToString().ToLower() == "false" || dr["IsOnline"].ToString() == "0")<br /> isOnline = false; <br /> <br /> //Inform all online friends that one user has logged in.<br /> if (isOnline)<br /> {<br /> //Clients.Caller.Hello(isOnline.ToString() + " | Inform start." + DateTime.Now.ToShortTimeString());<br /> try<br /> {<br /> OnlineUser onlineFriend = OnlineUsers.FirstOrDefault(x => x.MyId == dr["FriendUId"].ToString());<br /> if (onlineFriend!=null)<br /> Clients.Client(onlineFriend.ConnectionId).refreshfriendlist(myid, name); //Send new logged in user's information to all friends<br /> else //User is online as DB entry but not exists in Array, hence need to set offline in DB<br /> {<br /> objChat.SetOffline(dr["FriendUId"].ToString());<br /> }<br /> }<br /> catch(Exception ex)<br /> {<br /> Clients.Caller.Hello("Error! "+ex.Message+"<br/>"+ ex.StackTrace.ToString());<br /> }<br /> //Clients.Caller.Hello(isOnline.ToString() + " | Inform end." + DateTime.Now.ToShortTimeString());<br /> }<br /> else<br /> {<br /> break;<br /> }<br /> }<br /> <br /> //Send online and offline friend list to caller<br /> string onlineUserList = UtilityChat.DataTableToJson(dt);<br /> Clients.Caller.friendslist(onlineUserList);<br /> <br /> }<br /> public void createnewchatid(string fromuid, string touid)<br /> {<br /> string newChatOrGroupId = objChat.GetNewChatOrGroupId();<br /> objChat.AddUserInChat(newChatOrGroupId,fromuid);<br /> objChat.AddUserInChat(newChatOrGroupId, touid);<br /> Clients.Caller.newchatid(newChatOrGroupId, touid);<br /> }<br /> public void sendpvtmsg(string chatorgroupid,string fromid, string fromname,string toid,string pvtmsg)<br /> {<br /> objChat.AddNewMessage(chatorgroupid, fromid, pvtmsg);<br /> OnlineUser onlineFriend = OnlineUsers.FirstOrDefault(x => x.MyId == toid);<br /> if (onlineFriend != null)<br /> Clients.Client(onlineFriend.ConnectionId).receivepvtmsg(chatorgroupid, fromid, fromname, pvtmsg);<br /> }<br /> public void nonmessage_control_info(string fromid, string fromname,string toid,string signal)//'Signal' is used to indicate, Typing, Away etc.<br /> {<br /> OnlineUser onlineFriend = OnlineUsers.FirstOrDefault(x => x.MyId == toid);<br /> if (onlineFriend != null)<br /> Clients.Client(onlineFriend.ConnectionId).incoming_control_msg(fromid, fromname, signal);<br /> }<br /> <br /> public override System.Threading.Tasks.Task OnDisconnected()<br /> {<br /> OnlineUser onlineUser = OnlineUsers.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId);<br /> if (onlineUser != null)<br /> {<br /> bool isOnline = false;<br /> objChat.SetOffline(onlineUser.MyId);<br /> dt = objChat.GetFriendLoginStatus(onlineUser.MyId);<br /> foreach (DataRow dr in dt.Rows)<br /> {<br /> if(dr["IsOnline"].ToString().ToLower() == "true" || dr["IsOnline"].ToString() == "1")<br /> isOnline=true;<br /> else if(dr["IsOnline"].ToString().ToLower() == "true" || dr["IsOnline"].ToString() == "1")<br /> isOnline=false;<br /> //Inform all online friends that one user has logged in.<br /> if (isOnline)<br /> {<br /> OnlineUser onlineFriend = OnlineUsers.FirstOrDefault(x => x.MyId == dr["FriendUId"].ToString());<br /> if (onlineFriend != null)<br /> {<br /> Clients.Client(onlineFriend.ConnectionId).logoffuser(onlineUser.MyId);<br /> // Clients.Client(onlineFriend.ConnectionId).incoming_control_msg(onlineUser.MyId, onlineUser.Name, "offline"); //Not developed, keep aside for future feature<br /> }<br /> }<br /> else<br /> {<br /> break;<br /> }<br /> }<br /> OnlineUsers.Remove(onlineUser);<br /> }<br /> return base.OnDisconnected();<br /> } <br /> }<br /> public class OnlineUser<br /> {<br /> //public OnlineUser(string MyId, string Name, string EmailId, string ConnectionId)<br /> //{<br /> // this.myId = MyId; <br /> // this.connectionId = ConnectionId;<br /> //}<br /> public string MyId { get; set; }<br /> public string ConnectionId { get; set; }<br /> public string Name { get; set; }<br /> }<br />}</blockquote>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com8tag:blogger.com,1999:blog-4193683792173214666.post-89088011684839757662014-03-11T11:12:00.003+05:302014-03-26T00:35:33.355+05:30MVC with ADO.Net on MySQL (using Stored Procedure)<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">I am really excited to share this piece of unique code with you. Really this is different MVC without entity framework and based on traditional ADO.Net and database not even MS SQL its MySQL! Yes I am going to share these different type code with all of you.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Before sharing code I would like to tell a brief background about why I have tried it. I have websites all were built on traditional ASP.Net with ADO.Net and now I am trying to migrate these in MVC. But to move everything in MVC at a time will be a big problem, hence I am trying to do it part by part and I believe with ADO.Net MVC will work great. So I do not need to modify database or database access layer. This will reduce my effort and cost.</span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Next is why MySQL not MS SQL? Reason is, I have small budget for these websites and MS SQL express great for this for now. But in future if I need database more than 10GB or 1GB RAM support for better database operation then MS SQL Express will be a bar for me and paid version is seems very costly according to INR currency. But MySQL enterprise also is free to use and this I am using since last more than 1 year in production on Windows 2008 server without any single problem. About to decide MySQL I get confidence from Google, Facebook, Yahoo etc. companies because so far I know they are all doing their work on MySQL only.</span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">I believe it was a nice explanation about background, now lets come on coding part.</span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Coding with MySQL is almost similar to MS SQL on .Net part. Just you need to add some reference of MySQL's ADO.Net DLLs and next you need to use MySQL name space in your code. For connection, command, DataAdapter you need to refer MySQL connection, MySQL Command and MySQLDataAdapter. Your calling process and other part will be exactly same. DataTable, DataSet will be same as MS SQL.</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuuMB7f-ru-ubqwJmes2OXvUo9X836mchKbHYy4ImrDysFCzYNbnB0ud_PUwSqQaWG1PjYnSUXfbtYPcpYzKzYzo5FMNkJu6AFQO-PL-XdEaLFOcToFdaezsbgfBlkVyfvP68mGY6fjWc/s1600/MySQLReference.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuuMB7f-ru-ubqwJmes2OXvUo9X836mchKbHYy4ImrDysFCzYNbnB0ud_PUwSqQaWG1PjYnSUXfbtYPcpYzKzYzo5FMNkJu6AFQO-PL-XdEaLFOcToFdaezsbgfBlkVyfvP68mGY6fjWc/s1600/MySQLReference.jpg" /></a></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">In the picture you can see I have added 4 dll files to enable MySQL database access. In MySQL website they share DLLs for specific .Net versions. I am using .Net 4.5 hence I took this files. Files are in source code so for .Net 4.5 you can use these file in your project.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">To access MySQL database I have setup my connection string like below:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><add name="connStr" connectionString="server=localhost;user=root;database=world;port=3306;password=****" providerName="MySql.Data.MySqlClient"/></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">My project structure as below:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn0zH2YFfASbi-noqatTTd4zLvfq0ke18IpaNG-4UxISosHKaFA15PiDgHstXaVAQ4AvZTTpEGv0dEh2xI1tug2ZJgaze0o1yzTIZvBKWDXjbnOT0buZXVXcMhIqIEkK6-WYcVS6c0YtE/s1600/MVC_MySQL.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn0zH2YFfASbi-noqatTTd4zLvfq0ke18IpaNG-4UxISosHKaFA15PiDgHstXaVAQ4AvZTTpEGv0dEh2xI1tug2ZJgaze0o1yzTIZvBKWDXjbnOT0buZXVXcMhIqIEkK6-WYcVS6c0YtE/s1600/MVC_MySQL.jpg" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">In this screenshot AllCountries.xshtml is my view in Razor format, CountryController.cs is my controller and Contry.cs is my model where I have written my data access code. Its exactly similar like other ADO.Net data access code. </span></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">I am using MySQL's provided database (schema) 'world' for my example. 'world' schema is containing one table 'country' and it is containing data about countries, I am going to use these to show my example. Table structure is very simple and it is as below</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ofzFrGuUUgbsMlOgN43i7DaByiolt0RFNdSdg9Lfbcu1O3TKAz7O8rfK67UY3gmJd44A-Vs0P0VicP9GU-9nt1trKYeo2jPFqFFnGatMBenaWlzvNeNtK9LOsuaVjxUsRxQi1NU_XXw/s1600/Country.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ofzFrGuUUgbsMlOgN43i7DaByiolt0RFNdSdg9Lfbcu1O3TKAz7O8rfK67UY3gmJd44A-Vs0P0VicP9GU-9nt1trKYeo2jPFqFFnGatMBenaWlzvNeNtK9LOsuaVjxUsRxQi1NU_XXw/s1600/Country.jpg" height="262" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">To get data from 'country' table I have developed 'GetCountryList' Stored Procedure which I shall call from code.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">USE `world`;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">DELIMITER $$</span> </blockquote>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">USE `world`$$</span> </blockquote>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCountryList`( )</span> </blockquote>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;"> BEGIN<span class="Apple-tab-span" style="white-space: pre;"> </span></span> </blockquote>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;"> select * from world.country;</span> </blockquote>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;"> END$$</span> </blockquote>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">DELIMITER ;</span></blockquote>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">My model class - 'Country.cs' as below:</span><br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">using System;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Collections.Generic;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Linq;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Web;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Data;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using MySql.Data.MySqlClient;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Configuration;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Web.Security;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">namespace World</span><br />
<span style="font-family: Courier New, Courier, monospace;">{</span><br />
<span style="font-family: Courier New, Courier, monospace;"> public class Country</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> string connStr;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> MySqlConnection cnn;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> MySqlCommand cmd;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> public Country()</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> connStr = ConfigurationManager.ConnectionStrings["connStr"].ToString();</span><br />
<span style="font-family: Courier New, Courier, monospace;"> cnn = new MySqlConnection(connStr);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> public DataTable GetCountryList()</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> DataTable dt = new DataTable();</span><br />
<span style="font-family: Courier New, Courier, monospace;"> cmd = new MySqlCommand("GetCountryList");</span><br />
<span style="font-family: Courier New, Courier, monospace;"> cmd.CommandType = CommandType.StoredProcedure;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> cmd.Connection = cnn;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> MySqlDataAdapter adap = new MySqlDataAdapter(cmd);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if (cnn.State != ConnectionState.Open ||</span><br />
<span style="font-family: Courier New, Courier, monospace;"> cnn.State == ConnectionState.Broken ||</span><br />
<span style="font-family: Courier New, Courier, monospace;"> cnn.State != ConnectionState.Connecting ||</span><br />
<span style="font-family: Courier New, Courier, monospace;"> cnn.State != ConnectionState.Executing ||</span><br />
<span style="font-family: Courier New, Courier, monospace;"> cnn.State != ConnectionState.Fetching)</span><br />
<span style="font-family: Courier New, Courier, monospace;"> try</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> adap.Fill(dt);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> return dt;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"> catch (Exception ex)</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if (cnn.State != ConnectionState.Closed)</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> cnn.Close();</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"> return dt;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"> } </span><br />
<span style="font-family: Courier New, Courier, monospace;">}</span></blockquote>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">This model class is invoking stored procedure 'GetCountryList' and fetching data from database.</span><span style="font-family: Arial, Helvetica, sans-serif;"> Class is completely similar with my earlier project's data access layer class and there has no change, I am using it directly. To show as an example I made is simple with single stored procedure. There has some difference to access MySQL with MS SQL. Look for below codes</span></div>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">using MySql.Data.MySqlClient;</span></blockquote>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here I am using MySQLClient which we generally use SqlClient for MS SQL database and declaring MySQL Command, Connection and DataAdapter as below:</span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">MySqlConnection cnn;MySqlCommand cmd;MySqlDataAdapter adap = new MySqlDataAdapter(cmd);</span></blockquote>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">CountryController.cs</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Controller class for my project is very simple. This is just creating an object of my country class and invoking method to get data. This method will return a datatable and data table is sending to View.</span><br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">using System;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Collections.Generic;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Linq;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Web;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using System.Web.Mvc;</span><br />
<span style="font-family: Courier New, Courier, monospace;">using World;</span><br />
<span style="font-family: Courier New, Courier, monospace;">namespace MVC4.Controllers</span><br />
<span style="font-family: Courier New, Courier, monospace;">{</span><br />
<span style="font-family: Courier New, Courier, monospace;"> public class CountryController : Controller</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> public ActionResult AllCountries()</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> Country countries = new Country();</span><br />
<span style="font-family: Courier New, Courier, monospace;"> return View(countries.GetCountryList());</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;">}</span><br />
<div>
<br /></div>
</blockquote>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">View - AllCountries.cshtml, I am using Razor syntax to populate data in view and this is standalone/complete view without any layout of any other partial views. Code as below:</span></div>
<div>
<br /></div>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">@{<br /> Layout = null;<br />}<br /><!DOCTYPE html><br /><html><br /><head><br /> <meta name="viewport" content="width=device-width" /><br /> <title>AllCountries</title><br /></head><br /><body><br /> <div><br /> <table border="1" cellpadding="5"><br /> <thead><br /> <tr><br /> @foreach (System.Data.DataColumn col in Model.Columns)<br /> {<br /> <th>@col.Caption</th><br /> }<br /> </tr><br /> </thead><br /> <tbody><br /> @foreach (System.Data.DataRow row in Model.Rows)<br /> {<br /> <tr><br /> @foreach (var cell in row.ItemArray)<br /> {<br /> <td>@cell.ToString()</td><br /> }<br /> </tr><br /> }<br /> </tbody><br /> </table><br /> </div><br /></body><br /></html></span></blockquote>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">This is very simple code, Razor code is reading DataTable columns and priting these on html by below code. Razor is nothing new, its just earlier traditional things with new name with an @ sign. </span></div>
<div>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">@foreach (System.Data.DataColumn col in Model.Columns)<br />{<br /> <th>@col.Caption</th><br />}</span></blockquote>
</div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">This is normal foreach loop to print column caption.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">Below code is another foreach loop which is going through each cell and printing these.</span></div>
<div>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">@foreach (System.Data.DataRow row in Model.Rows)<br />{<br /> <tr><br /> @foreach (var cell in row.ItemArray)<br /> {<br /> <td>@cell.ToString()</td><br /> }<br /> </tr><br />}</span></blockquote>
</div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">After executing these codes, output will show like below.</span></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3CzYLnzyBJiFMdU6n63GkXxrEBOZ0UzMOt003dGFj_4PREE4xhLIObfsegQm52S2HgC3gCujTeLcPkr2W0Fi20EMZccweUQ2gzC437AhYaQ5dffwKcTuYTqcZV9uTVD3Xc6wSikUUT2I/s1600/output.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3CzYLnzyBJiFMdU6n63GkXxrEBOZ0UzMOt003dGFj_4PREE4xhLIObfsegQm52S2HgC3gCujTeLcPkr2W0Fi20EMZccweUQ2gzC437AhYaQ5dffwKcTuYTqcZV9uTVD3Xc6wSikUUT2I/s1600/output.jpg" height="140" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<span style="font-family: Arial, Helvetica, sans-serif;">Thank you for reading my blog. You can download full source code from here.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br /></span></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com2tag:blogger.com,1999:blog-4193683792173214666.post-77206161862593144152014-02-25T10:27:00.000+05:302014-03-25T09:34:12.769+05:30In Memory Search using Lamda Expression: Realtime Chat application on web in ASP.Net: Step 4<div dir="ltr" style="text-align: left;" trbidi="on">
Welcome at Realtime Chat application on web in ASP.Net using SignalR technology. This is step 4 and now we will learn how we can search in memory array without any loop like for, while etc. We will use Lamda expression to search an element in array list with generics. I shall not describe about these technologies from theoretical perspective, here I shall show some application of these. You can read theory of these things from MSDN site.<br />
<br />
You may think why this is require for our chat application, really good question. We shall use this technique to find an online user in server. However we can take database help to find online users but to minimize database operation I have used this technique. In chat application I have used a public static list (array) to hold online users, and from here I am searching users to generate online friend lists. By that way I have minimize a lot database operation and this technique can improve your chat application.<br />
<br />
Lets check the code first then shall describe the codes.<br />
<br />
HTML/ASP.Net part<br />
<blockquote class="tr_bq">
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><br />
<br />
<!DOCTYPE html><br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server"><br />
<title></title><br />
</head><br />
<body><br />
<form id="form1" runat="server"><br />
<h1>In memory search using Lamda Expression in C#.Net</h1><br />
<h3>Search country calling code</h3><br />
<p><br />
Country Name:<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
&nbsp;<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Find Calling Code" /><br />
</p><br />
<p><br />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label><br />
</p><br />
<a href="http://en.wikipedia.org/wiki/List_of_country_calling_codes" target="_blank">Full list is available here</a><br />
</form><br />
</body><br />
</html></blockquote>
and the C# code as below:<br />
<br />
<blockquote class="tr_bq">
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Web;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
<br />
public partial class _Default : System.Web.UI.Page<br />
{<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{ <br />
}<br />
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
FindCallingCode();<br />
}<br />
private void FindCallingCode()<br />
{<br />
//In real use databind before searching, using by that way as demo<br />
List<Country> countries = new List<Country>();<br />
countries.Add(new Country { callingCode = "+91", name = "India" });<br />
countries.Add(new Country { callingCode = "+44", name = "UK" });<br />
countries.Add(new Country { callingCode = "+1", name = "USA" });<br />
countries.Add(new Country { callingCode = "+88", name = "Bangladesh" });<br />
countries.Add(new Country { callingCode = "+49", name = "Germany" });<br />
countries.Add(new Country { callingCode = "+33", name = "France" });<br />
countries.Add(new Country { callingCode = "+55", name = "Brazil" });<br />
<br />
Country country = countries.FirstOrDefault(x => x.name.ToLower() == TextBox1.Text.Trim().ToLower());<br />
if (country != null)<br />
Label1.Text = "Calling code of " + country.name + " is " + country.callingCode;<br />
else<br />
Label1.Text = TextBox1.Text + " Not Found in our Country List";<br />
}<br />
}<br />
public class Country { <br />
public string callingCode { get; set; }<br />
public string name { get; set; }<br />
}</blockquote>
Here is main method is "FindCallingCode()" and class "Country". Here I am doing all operations. Lets look at some important code.<br />
<br />
Country class: This class I have defined to create country objects which will store country name and calling code. If you need extra properties you can add these easily.<br />
<br />
<blockquote class="tr_bq">
List<Country> countries = new List<Country>();</blockquote>
In the above code I have defined a list (array) of county objects with name countries. Naming convention using as this variable holding multiple country hence its plural name of country.<br />
<br />
<blockquote class="tr_bq">
countries.Add(new Country { callingCode = "+91", name = "India" });</blockquote>
In the above line of code I have adding element of array by creating country class object.<br />
<br />
<blockquote class="tr_bq">
Country country = countries.FirstOrDefault(x => x.name.ToLower() == TextBox1.Text.Trim().ToLower());</blockquote>
This is actually Lamda expression "x=>x.name" this is doing searching operation with method "FirstOrDefault". This line searching all element and doing comparison with user entered country name and stored country name. When matched it will return the country object.<br />
<blockquote class="tr_bq">
Label1.Text = "Calling code of " + country.name + " is " + country.callingCode;</blockquote>
In previous line of code we have found country object from array of countries and now getting calling code and name from the found object.<br />
<br />
In my chat application I have used mainly this (FirstOrDefault) method and for some cases have used "Count", "Find" methods/properties. "Find" and "FirstOrDefault" both can do a bit similar work but "Find" is very fast (in a blog I found 1000 times) than "FirstOrDefault", hence I am using as and when these are suitable.<br />
For your knowledge you can check other methods as well.<br />
<br />
Thanks for reading my blog please visit again for next article.<br />
<br />
Source code is available <a href="http://onlyms.net/FILES%2f2014%2f02%2fBlog_LamdaExpression.zip.axdx" target="_blank">here</a>.<br />
<br /></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-62349497815956763042014-02-20T00:38:00.000+05:302014-03-25T09:34:22.094+05:30Send client message to server using SignalR method - Realtime Chat application on web in ASP.Net: Step 3<div dir="ltr" style="text-align: left;" trbidi="on">
This will be my 3rd post on SignalR technology. In previous post I shown how to get server time using SignalR client method, which will be called from server side. Now I shall show how to transfer data between server and client.<br />
<br />
This is very simple solution and it can do as same way as normal .Net method calling with parameter.<br />
<br />
I am not explaining these code again as I did it last time.<br />
<br />
Startup.cs<br />
<br />
<blockquote class="tr_bq">
using Microsoft.Owin;<br />
using Owin;<br />
[assembly: OwinStartup(typeof(SignalRChat.Startup))]<br />
namespace SignalRChat<br />
{<br />
public class Startup<br />
{<br />
public void Configuration(IAppBuilder app)<br />
{<br />
// Any connection or hub wire up and configuration should go here<br />
app.MapSignalR();<br />
}<br />
}<br />
}</blockquote>
<br />
ChatHub.cs file code:<br />
<br />
<blockquote class="tr_bq">
using System;<br />
using System.Web;<br />
using Microsoft.AspNet.SignalR;<br />
namespace SignalRChat<br />
{<br />
public class ChatHub : Hub<br />
{<br />
/// <summary><br />
/// getservertime<br />
/// </summary><br />
public void getservertime()<br />
{<br />
Clients.Caller.serverresponse("This is server response. Server is calling client method from server. <br/> Server time is: " + DateTime.Now.ToShortTimeString());<br />
}<br />
<br />
public void sendmessage(string usermessage)<br />
{<br />
Clients.Caller.serverresponse(usermessage + " :This is server message <br/>");<br />
}<br />
}<br />
}</blockquote>
In this code I have added new method "sendmessage(parameter1)" and it will call same client method to return data to client. This is very simple code.<br />
<br />
<br />
Next will come HTML part, which is as below:<br />
<br />
<br />
<br />
<br />
<blockquote class="tr_bq">
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><br />
<br />
<!DOCTYPE html><br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server"><br />
<br />
<title>SignalR Simple Chat</title><br />
<style type="text/css"><br />
.container {<br />
background-color: #99CCFF;<br />
border: thick solid #808080;<br />
padding: 20px;<br />
margin: 20px;<br />
}<br />
</style><br />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /><br />
<br />
<!--Reference the jQuery library. --><br />
<script src="Scripts/json2.js"></script><br />
<script src="Scripts/jquery-1.10.2.js"></script><br />
<script src="Scripts/jquery-1.10.2.min.js"></script><br />
<br />
<!--Reference the SignalR library. --><br />
<script src="Scripts/jquery.signalR-2.0.0.js"></script><br />
<script src="Scripts/jquery.signalR-2.0.0.min.js"></script><br />
<br />
<!--Reference the autogenerated SignalR hub script. --><br />
<script src="/signalr/hubs"></script><br />
<!--Add script to update the page and send messages.--><br />
<br />
<script type="text/javascript"><br />
$(function () {<br />
// Declare a proxy to reference the hub.<br />
var chat = $.connection.chatHub;<br />
<br />
<br />
//Write your server response related code here<br />
chat.client.serverresponse = function (message) {<br />
$('#dvServerResponse').append(message);<br />
};<br />
<br />
// Start the connection.<br />
$.connection.hub.start().done(function () {<br />
//Write your server invoke related code here<br />
$('#btnHello').click(function () {<br />
console.log('call server');<br />
chat.server.sendmessage($('#txt').val());<br />
});<br />
});<br />
});<br />
</script><br />
<br />
</head><br />
<body><br />
<form id="form1" runat="server"><br />
<div><br />
<div><br />
Enter your message: <input type="text" id="txt" /><br /><br />
<input type="button" id="btnHello" value="Send message to server" /> <br />
<br />
<div id="dvServerResponse"></div> <br />
<br />
</div><br />
</div><br />
</form><br />
</body><br />
</html></blockquote>
When you will run this in browser it will show as below:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjapdntf4_J_2JRduIRwlBfmmUTJtDlYrMXSfba8hYRhQOUSGJ0Wj4n_yQeVmvOZ8DTheyDAydEWE6JnLdXLt1k8UVO9-zss0amW56ALSgdUouNWxedyxEJiCpffzddnWPzl3Wn5tKINCY/s1600/SignalR3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjapdntf4_J_2JRduIRwlBfmmUTJtDlYrMXSfba8hYRhQOUSGJ0Wj4n_yQeVmvOZ8DTheyDAydEWE6JnLdXLt1k8UVO9-zss0amW56ALSgdUouNWxedyxEJiCpffzddnWPzl3Wn5tKINCY/s1600/SignalR3.jpg" height="224" width="320" /></a></div>
<br />
Hope you have enjoyed this post and please visit my blog again.<br />
<br />
Next will show something about Lamda Expression which I shall use in my chat application.<br />
<br />
<br />
<br /></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-88519367405498890902014-02-19T00:38:00.002+05:302014-03-25T09:34:35.876+05:30Get Server time - Realtime Chat application on web in ASP.Net using SignalR Technology: Step 2<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
In <a href="http://onlyms.net/category/SignalR">previous post</a> I
have describe how to set up your project for SignalR with require
software. Now I shall show to get server time and how can invoke a
server method as request and how can get response with server time by
calling client javascript method from server end.<br />
Again here will be these main part of coding and here I am not changing anything in Startup.cs file. This code as it is.<br />
<br />
<blockquote class="tr_bq">
using Microsoft.Owin;<br />
using Owin;<br />
[assembly: OwinStartup(typeof(SignalRChat.Startup))]<br />
namespace SignalRChat<br />
{<br />
public class Startup<br />
{<br />
public void Configuration(IAppBuilder app)<br />
{<br />
// Any connection or hub wire up and configuration should go here<br />
app.MapSignalR();<br />
}<br />
}<br />
} </blockquote>
<br />
Next is ChatHub.cs and here is very small code as below:<br />
<br />
<blockquote class="tr_bq">
using System;<br />
using System.Web;<br />
using Microsoft.AspNet.SignalR;<br />
namespace SignalRChat<br />
{<br />
public class ChatHub : Hub<br />
{<br />
public void getservertime() {<br />
Clients.Caller.serverresponse("This is server response. Server is calling client method from server. <br />
Server time is: " + DateTime.Now.ToShortTimeString());<br />
}<br />
}<br />
}</blockquote>
<br />
Here I have added on public method "getservertime()". Note here I
have written all method in small letters and shall call this from client
javascript in small letters only. Previously I have tested by writing
in capital letters and have seen this is not working. So I would suggest
to write these methods always in small letters only, to avoid
difficulties.<br />
<br />
"getservertime()" is very small method which will invoked by client
on button press and this method will invoke a client's javascript method
to send response to client. Note here I am writting 'Clients.Caller' to
find out the client from where server method has invoked. If I need to
call any different client's method (usually for chat application one
user will send method to other, so one client will invoke server method
and server method will call other client's client method. These things I
shall show later) then there will be some different way, which I shall
explain later. After 'Client.Caller' method name is coming that is
"serverresponse()". This client method is passing argument and this will
deliver server message to client.<br />
<br />
Next I shall explain about client code and these all are HTML and Javascript only.<br />
<br />
<blockquote class="tr_bq">
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><br />
<br />
<!DOCTYPE html><br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server"><br />
<br />
<title>SignalR Simple Chat</title><br />
<style type="text/css"><br />
.container {<br />
background-color: #99CCFF;<br />
border: thick solid #808080;<br />
padding: 20px;<br />
margin: 20px;<br />
}<br />
</style><br />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /><br />
<br />
<!--Reference the jQuery library. --><br />
<script src="Scripts/json2.js"></script><br />
<script src="Scripts/jquery-1.10.2.js"></script><br />
<script src="Scripts/jquery-1.10.2.min.js"></script><br />
<br />
<!--Reference the SignalR library. --><br />
<script src="Scripts/jquery.signalR-2.0.0.js"></script><br />
<script src="Scripts/jquery.signalR-2.0.0.min.js"></script><br />
<br />
<!--Reference the autogenerated SignalR hub script. --><br />
<script src="/signalr/hubs"></script><br />
<!--Add script to update the page and send messages.--><br />
<br />
<script type="text/javascript"><br />
$(function () {<br />
// Declare a proxy to reference the hub.<br />
var chat = $.connection.chatHub;<br />
<br />
<br />
//Write your server response related code here<br />
chat.client.serverresponse = function (message) {<br />
$('#dvServerResponse').append(message);<br />
};<br />
<br />
// Start the connection.<br />
$.connection.hub.start().done(function () {<br />
//Write your server invoke related code here<br />
$('#btnHello').click(function () {<br />
console.log('call server');<br />
chat.server.getservertime();<br />
});<br />
});<br />
});<br />
</script><br />
<br />
</head><br />
<body><br />
<form id="form1" runat="server"><br />
<div><br />
<div><br />
<div id="dvServerResponse"></div> <br />
<input type="button" id="btnHello" value="Get Server Time" /> <br />
</div><br />
</div><br />
</form><br />
</body><br />
</html></blockquote>
</div>
<br />
These HTML and Javascript code I have written in ASP.Net file however this will work in normal HTML file as well.<br />
Initial part is javascript library file referencing section. Here I
am calling files in three steps, first JSON and JQeury files, next
SignalR library and finally Hub files. Next starting custom java script
codes.<br />
<br />
In java script code firstly I have created a proxy of chatHub. Next code is<br />
<br />
<blockquote class="tr_bq">
<div class="container">
<div class="line number1 index0 alt2">
<code class="c-sharp comments">//Write your server response related code here</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">chat.client.serverresponse = function (message) {</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">$(</code><code class="c-sharp string">'#dvServerResponse'</code><code class="c-sharp plain">).append(message);</code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">};</code></div>
</div>
</blockquote>
<br />
For time being you can assume this is standard syntax of creating
client methods which will be called from server and within this cal
implement client activities. For my case I am appending server response
at div.<br />
<br />
Other part of client codes as below<br />
<br />
<blockquote class="tr_bq">
<div class="container">
<div class="line number1 index0 alt2">
<code class="c-sharp comments">//Write your server invoke related code here</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp plain">$(</code><code class="c-sharp string">'#btnHello'</code><code class="c-sharp plain">).click(function () {</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">console.log(</code><code class="c-sharp string">'call server'</code><code class="c-sharp plain">);</code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">chat.server.getservertime();</code></div>
<div class="line number5 index4 alt2">
<code class="c-sharp plain">});</code></div>
</div>
<br /></blockquote>
This method will start executing once btnHello clicked and it will
invoke server method to get server response. Here to invoke server
method syntax like "chat.server.getservertime()" or
"proxy-object.server.server-method()".<br />
<br />
Finally result will displayed in client browser.<br />
<br />
<a href="http://sumanbiswas.com/blogsourcecodes/SignalRChat_Step2_GetServerTime.zip" target="_blank">Here is the full code.</a><br />
<br />
Thanks for reading my blog.<br />
<br />
<br />
<br /></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-5450569865827573812014-02-18T20:32:00.000+05:302014-03-25T09:34:51.051+05:30SignalR - Hello World: Real time chat application on Web in ASP.Net using SignalR technology : Step 1<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">Programming
with distributed technology is my passion. Earlier I have worked with
Remoting, Socket, Web Service and a bit with WCF. So when I first came
to know about SignalR technolog, really I can not wait to start coding
on it. Now I can able to write own chat application for <a href="http://alap.me/">AlapMe</a>
and really its working fine. Most of all by using SignalR I can use
socket of HTML5. I shall write multiple posts on SignalR as tutorial as I
did in past with C# Socket programming. I shall publish these posts on
this blog and on my <a href="http://socketprogramming.blogspot.co.com/">socket programming</a> blog as well.</span><br />
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">I have started SignalR programming with Visual Studio Express 2013 which is freely downloadable from <a href="http://www.asp.net/signalr">here</a>.
Also you can read full documentation from Microsoft from this link. As
my target to share some practical example with ready to use code hence I
shall not describe in detail about the technology. You can follow
Microsoft documentation website for it. </span><br />
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">To start with SignalR first coding you need to follow steps are below.</span><br />
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">Lunch
your VS 2013 and create a blank project and add new item of SignalR Hub
Class (v2) set its name as you wish, for my case its MyHub.cs. When you
will add this class Visual Studio automatically add all related
references and jquery classes. To add these things it may take some time
may be 2-3 minutes. This new item will come with a sample method
'Hello()', for now just follow these later I shall describe what is
these things and why these are. Full code will look like below:</span><br />
<br />
<div class="container">
<div class="line number1 index0 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System;</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System.Collections.Generic;</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System.Linq;</code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System.Web;</code></div>
<div class="line number5 index4 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">Microsoft.AspNet.SignalR;</code></div>
<div class="line number6 index5 alt1">
</div>
<div class="line number7 index6 alt2">
<code class="c-sharp keyword">namespace</code> <code class="c-sharp plain">SignalR_Learning</code></div>
<div class="line number8 index7 alt1">
<code class="c-sharp plain">{</code></div>
<div class="line number9 index8 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">class</code> <code class="c-sharp plain">MyHub : Hub</code></div>
<div class="line number10 index9 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">{</code></div>
<div class="line number11 index10 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">void</code> <code class="c-sharp plain">Hello()</code></div>
<div class="line number12 index11 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">{</code></div>
<div class="line number13 index12 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">Clients.All.hello();</code></div>
<div class="line number14 index13 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">}</code></div>
<div class="line number15 index14 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">}</code></div>
<div class="line number16 index15 alt1">
<code class="c-sharp plain">}</code></div>
<div class="line number16 index15 alt1">
</div>
<div class="line number16 index15 alt1">
<code class="c-sharp plain"><span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">Now
go to next step and add next item in project, that is OWIN Startup
class. I am giving its default name 'Startup1.cs' for my sample project.
Visual Studio will create this file with some pre-added code. We will
extend these code as per your needs. Code as below:</span></code></div>
<div class="line number16 index15 alt1">
</div>
<div class="line number16 index15 alt1">
<br />
<div class="container">
<div class="line number1 index0 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System;</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System.Threading.Tasks;</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">Microsoft.Owin;</code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">Owin;</code></div>
<div class="line number5 index4 alt2">
</div>
<div class="line number6 index5 alt1">
<code class="c-sharp plain">[assembly: OwinStartup(</code><code class="c-sharp keyword">typeof</code><code class="c-sharp plain">(SignalR_Learning.Startup1))]</code></div>
<div class="line number7 index6 alt2">
</div>
<div class="line number8 index7 alt1">
<code class="c-sharp keyword">namespace</code> <code class="c-sharp plain">SignalR_Learning</code></div>
<div class="line number9 index8 alt2">
<code class="c-sharp plain">{</code></div>
<div class="line number10 index9 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">class</code> <code class="c-sharp plain">Startup1</code></div>
<div class="line number11 index10 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">{</code></div>
<div class="line number12 index11 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">void</code> <code class="c-sharp plain">Configuration(IAppBuilder app)</code></div>
<div class="line number13 index12 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">{</code></div>
<div class="line number14 index13 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp comments">// For more information on how to configure your application, visit <a href="http://go.microsoft.com/fwlink/?LinkID=316888">http://go.microsoft.com/fwlink/?LinkID=316888</a></code></div>
<div class="line number15 index14 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">}</code></div>
<div class="line number16 index15 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">}</code></div>
<div class="line number17 index16 alt2">
<code class="c-sharp plain">}</code></div>
<div class="line number17 index16 alt2">
</div>
<div class="line number17 index16 alt2">
<code class="c-sharp plain"><span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">In method Configuration I shall add just a line of code 'app.MapSignalR();' so full method will look like:</span></code></div>
<div class="line number17 index16 alt2">
</div>
<div class="line number17 index16 alt2">
<div class="container">
<div class="line number1 index0 alt2">
<code class="c-sharp keyword">public</code> <code class="c-sharp keyword">void</code> <code class="c-sharp plain">Configuration(IAppBuilder app)</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp plain">{</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp comments">// For more information on how to configure your application, visit <a href="http://go.microsoft.com/fwlink/?LinkID=316888">http://go.microsoft.com/fwlink/?LinkID=316888</a></code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">app.MapSignalR();</code></div>
<div class="line number5 index4 alt2">
<code class="c-sharp plain">}</code></div>
<div class="line number5 index4 alt2">
</div>
<div class="line number5 index4 alt2">
<code class="c-sharp plain"> </code><span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">Now
we will move to front end coding and this part will develop with simple
HTML page, however you can use ASPX page as well. Now I have added a
HTML page with name 'index.html'</span></div>
<div class="line number5 index4 alt2">
</div>
<div class="line number5 index4 alt2">
<div class="container">
<div class="line number1 index0 alt2">
<code class="js plain"><! DOC TYPE ht ml ></code></div>
<div class="line number2 index1 alt1">
<code class="js plain">< ht ml xmlns=</code><code class="js string">"<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"</code><code class="js plain"> ></code></div>
<div class="line number3 index2 alt2">
<code class="js plain"><he ad=""></he></code></div>
<div class="line number4 index3 alt1">
<code class="js spaces"> </code><code class="js plain"><ti tle="">SignalR Simple Chat</ti></code></div>
<div class="line number5 index4 alt2">
<code class="js spaces"> </code><code class="js plain"><m eta="" http-equiv="</code"><code class="js string">"X-UA-Compatible"</code> <code class="js plain">content=</code><code class="js string">"IE=edge"</code> <code class="js plain">/ ></code></m></code></div>
<div class="line number6 index5 alt1">
</div>
<div class="line number7 index6 alt2">
<code class="js spaces"> </code><code class="js plain"><!--Script references. --></code></div>
<div class="line number8 index7 alt1">
<code class="js spaces"> </code><code class="js plain"><!--Reference the jQuery library. --></code></div>
<div class="line number9 index8 alt2">
<code class="js spaces"> </code><code class="js plain">< sc ript src=</code><code class="js string">"Scripts/jquery-1.10.2.js"</code><code class="js plain">></code></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="line number10 index9 alt1">
<code class="js spaces"> </code><code class="js plain">< sc ript src=</code><code class="js string">"Scripts/jquery-1.10.2.min.js"</code><code class="js plain">></code></div>
<br />
<div class="line number11 index10 alt2">
<code class="js spaces"> </code><code class="js plain">< scri pt src=</code><code class="js string">"Scripts/json2.js"</code><code class="js plain">></code></div>
<div class="line number12 index11 alt1">
</div>
<div class="line number13 index12 alt2">
<code class="js spaces"> </code><code class="js plain"><!--Reference the SignalR library. --></code></div>
<div class="line number14 index13 alt1">
<code class="js spaces"> </code><code class="js plain"><sc ript="" src="</code"><code class="js string">"Scripts/jquery.signalR-2.0.0.js"</code><code class="js plain">></code></sc></code></div>
<div class="line number15 index14 alt2">
<code class="js spaces"> </code><code class="js plain"><scri pt="" src="</code"><code class="js string">"Scripts/jquery.signalR-2.0.0.min.js"</code><code class="js plain">></code></scri></code></div>
<div class="line number16 index15 alt1">
<code class="js spaces"> </code><code class="js plain"><!--Reference the autogenerated SignalR hub script. --></code></div>
<div class="line number17 index16 alt2">
<code class="js spaces"> </code><code class="js plain"><scr ipt="" src="</code"><code class="js string">"/signalr/hubs"</code><code class="js plain">></code></scr></code></div>
<div class="line number18 index17 alt1">
<code class="js spaces"> </code><code class="js plain"><!--Add script to update the page and send messages.--></code></div>
<div class="line number19 index18 alt2">
</div>
<div class="line number20 index19 alt1">
<code class="js spaces"> </code><code class="js plain"><scr ipt="" nbsp="" type="</code"><code class="js string">"text/ "</code><code class="js plain">></code></scr></code></div>
<div class="line number21 index20 alt2">
<code class="js spaces"> </code><code class="js keyword">var</code> <code class="js plain">chat;</code></div>
<div class="line number22 index21 alt1">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js keyword">f unction</code> <code class="js plain">() {</code></div>
<div class="line number23 index22 alt2">
<code class="js spaces"> </code><code class="js comments">// Declare a proxy to reference the hub.</code></div>
<div class="line number24 index23 alt1">
<code class="js spaces"> </code><code class="js comments">//chat = $.hubConnection.myhub;</code></div>
<div class="line number25 index24 alt2">
<code class="js spaces"> </code><code class="js plain">chat = $.connection.myhub;</code></div>
<div class="line number26 index25 alt1">
<code class="js spaces"> </code><code class="js comments">//alert(chat);</code></div>
<div class="line number27 index26 alt2">
<code class="js spaces"> </code><code class="js plain">chat.client.hello = </code><code class="js keyword">function</code> <code class="js plain">(message) {</code></div>
<div class="line number28 index27 alt1">
<code class="js spaces"> </code><code class="js plain">alert(message);</code></div>
<div class="line number29 index28 alt2">
<code class="js spaces"> </code><code class="js plain">};</code></div>
<div class="line number30 index29 alt1">
</div>
<div class="line number31 index30 alt2">
<code class="js spaces"> </code><code class="js comments">// Start the connection.</code></div>
<div class="line number32 index31 alt1">
<code class="js spaces"> </code><code class="js plain">$.connection.hub.start().done(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div>
<div class="line number33 index32 alt2">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">'#btnhello'</code><code class="js plain">).click(</code><code class="js keyword">function</code> <code class="js plain">() { </code></div>
<div class="line number34 index33 alt1">
<code class="js spaces"> </code><code class="js plain">alert(chat);</code></div>
<div class="line number35 index34 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number36 index35 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number37 index36 alt2">
</div>
<div class="line number38 index37 alt1">
</div>
<div class="line number39 index38 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number40 index39 alt1">
<code class="js spaces"> </code><code class="js plain"></code></div>
<div class="line number41 index40 alt2">
<code class="js plain"></code></div>
<div class="line number42 index41 alt1">
<code class="js plain"><bo dy=""></bo></code></div>
<div class="line number43 index42 alt2">
<code class="js spaces"></code><br />
<div class="line number42 index41 alt1">
<code class="js plain"><bo dy=""></bo></code></div>
<div class="line number43 index42 alt2">
<code class="js spaces"> </code><code class="js plain"><i nput="" type="</code"><code class="js string">"button"</code> <code class="js plain">value=</code><code class="js string">"Hello"</code> <code class="js plain">id=</code><code class="js string">"btn hello"</code> <code class="js plain">/></code></i></code></div>
<div class="line number44 index43 alt1">
<code class="js plain"></code></div>
</div>
</div>
<div class="line number45 index44 alt2">
<code class="js plain"></code></div>
<code class="js plain"></code><code class="js plain"><code class="js plain"></code></code><br />
<div class="line number44 index43 alt1">
<code class="js plain"></code></div>
<div class="line number45 index44 alt2">
<code class="js plain"></code></div>
<div class="line number45 index44 alt2">
</div>
<div class="line number45 index44 alt2">
</div>
<br />
<div class="line number5 index4 alt2">
</div>
<div class="line number5 index4 alt2">
</div>
<div class="line number5 index4 alt2">
</div>
<br />
<div class="line number17 index16 alt2">
</div>
<div class="line number17 index16 alt2">
<code class="c-sharp plain"><span style="font-family: arial,helvetica,sans-serif; font-size: x-small;"> </span> </code></div>
<div class="line number16 index15 alt1">
</div>
<div class="line number16 index15 alt1">
<code class="c-sharp plain"><span style="font-family: arial,helvetica,sans-serif; font-size: x-small;"> </span> </code></div>
<br />
<br /></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-22035285044925895942014-02-01T20:33:00.000+05:302014-03-25T09:35:03.485+05:30Excel-VBA: Find Last Cell of Active WorkSheet<div dir="ltr" style="text-align: left;" trbidi="on">
Hello here is the code<br />
<br />
Public Function GetLastCellAddress() As String<br />
' Variables<br />
Dim intCol As Integer<br />
Dim lngRow As Long<br />
Dim rUsedRange As Range<br />
Dim rCell As Range<br />
<br />
' first unlock all cells<br />
Cells.Locked = False<br />
If WorksheetFunction.CountA(Cells) > 0 Then<br />
lngRow = Cells.Find(what:="*", After:=[A1], _<br />
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row<br />
intCol = Cells.Find(what:="*", After:=[A1], _<br />
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column<br />
Set rUsedRange = ActiveSheet.Range("$A$1" & ":" & Cells(lngRow, intCol).Address)<br />
<br />
lngRow = Cells.Find(what:="*", After:=[A1], _<br />
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row<br />
intCol = Cells.Find(what:="*", After:=[A1], _<br />
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column<br />
Set rUsedRange = ActiveSheet.Range("$A$1" & ":" & Cells(lngRow, intCol).Address)<br />
GetLastCellAddress = rUsedRange.Address<br />
End If<br />
End Function </div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-59801627130959747022014-01-14T15:52:00.001+05:302014-03-25T09:35:16.498+05:30Real time chat application on Web in ASP.Net using SignalR technology : Introduction<div dir="ltr" style="text-align: left;" trbidi="on">
I shall start posting code and description about how to create web chat application in asp.net using .Net's latest technology SignalR step by step. Also I shall share how to create server event based application. Already I have developed this chat server and using in my social website <a href="http://alap.me/">http://alap.me</a>.<br />
<br />
However I shall start posting on it step by step so a learner can learn it easily. I shall start from very begging with many small small things and shall cover ASP.Net parts and related stuff like jQuery, CSS, HTML5 or normal java script. Because all of these things will require to build full complete chat application.<br />
<br />
The same code I shall share which I have used in my <a href="http://alap.me/" target="_blank">social network site</a> chat part. I shall publish my code as open source so any one can use it in his application and any one can enhance it so other people can use it as like Linux did in early days. To use my chat application code just they need to mention in somewhere in this website (say at footer) a thanks to me with my personal website url that is http://sumanbiswas.com and just drop me a mail that they are using my code for my information. Whole code will be totally free of cost.<br />
<br />
So this is my introduction of chat application source code and from next I shall post it by step by step.<br />
<br /></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com1tag:blogger.com,1999:blog-4193683792173214666.post-36890458558663624432013-12-26T21:51:00.001+05:302014-03-25T09:35:27.398+05:30jQuery Tips: Develop infinite scrolling<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-size: small;">[Originally posted on <a href="http://onlyms.net/">http://onlyms.net</a>]</span><br />
<span style="font-size: small;">This simple below JQuery code can use for infinite scrolling. Just look into it, its extremely simple and easy task. Just follow below codes</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;">Java Script</span><br />
<span style="font-size: small;">Include JQuery file as below:</span><br />
<span style="font-size: small;"><br /></span>
<span style="background-color: #f3f3f3;"><span style="font-size: small;">< scri pt sr c="js/ jquery-1.10.2.js"></span></span></div>
<br />
< sc ript src="js/jquery-1.10.2.min.js"><span style="font-size: small;"><br /></span>
<span style="font-size: small;">and java script code as :</span><br />
<span style="font-size: small;"><br /></span>
<span style="background-color: #eeeeee;"><span style="font-size: small;"><s cr="" ipt="" pe="text/java script" ty=""><br /></s> $ ( func tion () {<br /> $(win dow) .scr oll(fu nction (ev ent) {<br /> cons ole.log($(".lo ad-more").off set().top < $(wi ndow).scroll Top() + $(win dow).outer Height()); // You can track if result is true or false<br /> if ($(". load-more").off set().top < $(win dow).scroll Top() + $(window).outer Height() == true) {<br /> //Method to load next page<br /> }<br /> else {<br /> //Do nothing or do as you want<br /> }<br /> });<br /> });<br /> < / sc ript</span></span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;">CSS section as below, just used for selector. You can update if you need.</span><br />
<span style="background-color: #eeeeee;"><span style="font-size: small;"><br /> .load-more {<br /> }<br /> </ sty l e</span></span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;">HTML part as below:</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><span style="background-color: #eeeeee;">< d iv><br /> < text area style="wi dth: 50%; hei ght: 110vh;"><br /> This is to fill full screen, so load more button go to invisible section<br />< / text area><br /> < in put clas s="load-more" val ue="load more" typ e="button" /><br /></ d iv></span></span><br />
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><br /></span></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-61575421541972488522013-12-22T00:07:00.000+05:302014-03-25T09:35:39.000+05:30Hello World with SignalR<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h4 style="text-align: left;">
<span style="font-size: small;"><span style="font-weight: normal;"><span style="font-family: arial,helvetica,sans-serif;">[Original Post from my blog <a href="http://onlyms.net/">OnlyMS.Net</a> for better visibility read it from OnlyMS.Net] </span></span></span></h4>
<span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">Programming
with distributed technology is my passion. Earlier I have worked with
Remoting, Socket, Web Service and a bit with WCF. So when I first came
to know about SignalR technolog, really I can not wait to start coding
on it. Now I can able to write own chat application for <a href="http://alap.me/">AlapMe</a>
and really its working fine. Most of all by using SignalR I can use
socket of HTML5. I shall write multiple posts on SignalR as tutorial as I
did in past with C# Socket programming. I shall publish these posts on
this blog and on my <a href="http://socketprogramming.blogspot.co.com/">socket programming</a> blog as well.</span></span><br />
<br />
<span style="font-size: small;">
</span><span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">I have started SignalR programming with Visual Studio Express 2013 which is freely downloadable from <a href="http://www.asp.net/signalr">here</a>.
Also you can read full documentation from Microsoft from this link. As
my target to share some practical example with ready to use code hence I
shall not describe in detail about the technology. You can follow
Microsoft documentation website for it. </span></span><br />
<br />
<span style="font-size: small;">
</span><span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">To start with SignalR first coding you need to follow steps are below.</span></span><br />
<span style="font-size: small;">
</span><span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">Lunch
your VS 2013 and create a blank project and add new item of SignalR Hub
Class (v2) set its name as you wish, for my case its MyHub.cs. When you
will add this class Visual Studio automatically add all related
references and jquery classes. To add these things it may take some time
may be 2-3 minutes. This new item will come with a sample method
'Hello()', for now just follow these later I shall describe what is
these things and why these are. Full code will look like below:</span></span><br />
<br />
<div class="container">
<div class="line number1 index0 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System;</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System.Collections.Generic;</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System.Linq;</code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System.Web;</code></div>
<div class="line number5 index4 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">Microsoft.AspNet.SignalR;</code></div>
<div class="line number6 index5 alt1">
</div>
<div class="line number7 index6 alt2">
<code class="c-sharp keyword">namespace</code> <code class="c-sharp plain">SignalR_Learning</code></div>
<div class="line number8 index7 alt1">
<code class="c-sharp plain">{</code></div>
<div class="line number9 index8 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">class</code> <code class="c-sharp plain">MyHub : Hub</code></div>
<div class="line number10 index9 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">{</code></div>
<div class="line number11 index10 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">void</code> <code class="c-sharp plain">Hello()</code></div>
<div class="line number12 index11 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">{</code></div>
<div class="line number13 index12 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">Clients.All.hello();</code></div>
<div class="line number14 index13 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">}</code></div>
<div class="line number15 index14 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">}</code></div>
<div class="line number16 index15 alt1">
<code class="c-sharp plain">}</code></div>
</div>
<br />
<br />
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;"><span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">Now
go to next step and add next item in project, that is OWIN Startup
class. I am giving its default name 'Startup1.cs' for my sample project.
Visual Studio will create this file with some pre-added code. We will
extend these code as per your needs. Code as below:</span> </span><br />
<br />
<h4 style="text-align: left;">
<span style="font-size: small;"><span style="font-weight: normal;"><span style="font-family: arial,helvetica,sans-serif;"> </span></span></span></h4>
<div class="container">
<div class="line number1 index0 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System;</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">System.Threading.Tasks;</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">Microsoft.Owin;</code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp keyword">using</code> <code class="c-sharp plain">Owin;</code></div>
<div class="line number5 index4 alt2">
</div>
<div class="line number6 index5 alt1">
<code class="c-sharp plain">[assembly: OwinStartup(</code><code class="c-sharp keyword">typeof</code><code class="c-sharp plain">(SignalR_Learning.Startup1))]</code></div>
<div class="line number7 index6 alt2">
</div>
<div class="line number8 index7 alt1">
<code class="c-sharp keyword">namespace</code> <code class="c-sharp plain">SignalR_Learning</code></div>
<div class="line number9 index8 alt2">
<code class="c-sharp plain">{</code></div>
<div class="line number10 index9 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">class</code> <code class="c-sharp plain">Startup1</code></div>
<div class="line number11 index10 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">{</code></div>
<div class="line number12 index11 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">void</code> <code class="c-sharp plain">Configuration(IAppBuilder app)</code></div>
<div class="line number13 index12 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">{</code></div>
<div class="line number14 index13 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp comments">// For more information on how to configure your application, visit <a href="http://go.microsoft.com/fwlink/?LinkID=316888">http://go.microsoft.com/fwlink/?LinkID=316888</a></code></div>
<div class="line number15 index14 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">}</code></div>
<div class="line number16 index15 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">}</code></div>
<div class="line number17 index16 alt2">
<code class="c-sharp plain">}</code></div>
</div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-weight: normal;"><span style="font-family: arial,helvetica,sans-serif;"> </span></span></span><span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">In method Configuration I shall add just a line of code 'app.MapSignalR();' so full method will look like:</span></div>
<h4 style="text-align: left;">
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;"> </span></h4>
<div class="container">
<div class="line number1 index0 alt2">
<code class="c-sharp keyword">public</code> <code class="c-sharp keyword">void</code> <code class="c-sharp plain">Configuration(IAppBuilder app)</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp plain">{</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp comments">// For more information on how to configure your application, visit <a href="http://go.microsoft.com/fwlink/?LinkID=316888">http://go.microsoft.com/fwlink/?LinkID=316888</a></code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">app.MapSignalR();</code></div>
<div class="line number5 index4 alt2">
<code class="c-sharp plain">}</code></div>
</div>
<div style="text-align: left;">
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;"> </span><span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">Now
we will move to front end coding and this part will develop with simple
HTML page, however you can use ASPX page as well. Now I have added a
HTML page with name 'index.html'</span></div>
<h4 style="text-align: left;">
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;"> </span><code class="js spaces"> </code><code class="js plain">< me ta http-equiv=</code><code class="js string">"X-UA-Compatible"</code> <code class="js plain">content=</code><code class="js string">"IE=edge"</code> <code class="js plain">/ ></code></h4>
<div class="line number6 index5 alt1">
</div>
<div class="line number7 index6 alt2">
<code class="js spaces"> </code><code class="js plain">< ! --Script references. --></code></div>
<div class="line number8 index7 alt1">
<code class="js spaces"> </code><code class="js plain">< ! --Reference the jQuery library. --></code></div>
<div class="line number9 index8 alt2">
<code class="js spaces"> </code><code class="js plain">< s cript src=</code><code class="js string">"Scripts/jquery-1.10.2.js"</code><code class="js plain">>< / scr ipt></code></div>
<div class="line number10 index9 alt1">
<code class="js spaces"> </code><code class="js plain">< s cript src=</code><code class="js string">"Scripts/jquery-1.10.2.min.js"</code><code class="js plain">>< / scr ipt> </code></div>
<div class="line number11 index10 alt2">
<code class="js spaces"> </code><code class="js plain">< s cript src=</code><code class="js string">"Scripts/json2.js"</code><code class="js plain">></ scr ipt></code></div>
<div class="line number12 index11 alt1">
</div>
<div class="line number13 index12 alt2">
<code class="js spaces"> </code><code class="js plain">< ! --Reference the SignalR library. - - ></code></div>
<div class="line number14 index13 alt1">
<code class="js spaces"> </code><code class="js plain">< s cript src=</code><code class="js string">"Scripts/jquery.signalR-2.0.0.js"</code><code class="js plain">>< / scr ipt></code></div>
<div class="line number15 index14 alt2">
<code class="js spaces"> </code><code class="js plain">< s cript src=</code><code class="js string">"Scripts/jquery.signalR-2.0.0.min.js"</code><code class="js plain">>< / scri pt></code></div>
<div class="line number16 index15 alt1">
<code class="js spaces"> </code><code class="js plain">< ! --Reference the autogenerated SignalR hub script. - - ></code></div>
<div class="line number17 index16 alt2">
<code class="js spaces"> </code><code class="js plain"><s cript="" src="</code"><code class="js string">"/signalr/hubs"</code><code class="js plain">></code></s></code></div>
</div>
<div class="line number18 index17 alt1">
<code class="js spaces"> </code><code class="js plain">< ! --Add script to update the page and send messages.-- ></code></div>
<h4 style="text-align: left;">
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;"> </span><code class="js spaces"></code><code class="js plain">< s cript type=</code><code class="js string">"text/java scri pt"</code><code class="js plain"> ></code></h4>
<div class="line number21 index20 alt2">
<code class="js spaces"> </code><code class="js keyword">var</code> <code class="js plain">chat;</code></div>
<div class="line number22 index21 alt1">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div>
<div class="line number23 index22 alt2">
<code class="js spaces"> </code><code class="js comments">// Declare a proxy to reference the hub.</code></div>
<div class="line number24 index23 alt1">
<code class="js spaces"> </code><code class="js comments">//chat = $.hubConnection.myhub;</code></div>
<div class="line number25 index24 alt2">
<code class="js spaces"> </code><code class="js plain">chat = $.connection.myhub;</code></div>
<div class="line number26 index25 alt1">
<code class="js spaces"> </code><code class="js comments">//alert(chat);</code></div>
<div class="line number27 index26 alt2">
<code class="js spaces"> </code><code class="js plain">chat.client.hello = </code><code class="js keyword">function</code> <code class="js plain">(message) {</code></div>
<div class="line number28 index27 alt1">
<code class="js spaces"> </code><code class="js plain">alert(message);</code></div>
<div class="line number29 index28 alt2">
<code class="js spaces"> </code><code class="js plain">};</code></div>
<div class="line number30 index29 alt1">
</div>
<div class="line number31 index30 alt2">
<code class="js spaces"> </code><code class="js comments">// Start the connection.</code></div>
<div class="line number32 index31 alt1">
<code class="js spaces"> </code><code class="js plain">$.connection.hub.start().done(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div>
<div class="line number33 index32 alt2">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">'#btnhello'</code><code class="js plain">).click(</code><code class="js keyword">function</code> <code class="js plain">() { </code></div>
<div class="line number34 index33 alt1">
<code class="js spaces"> </code><code class="js plain">alert(chat);</code></div>
<div class="line number35 index34 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number36 index35 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number37 index36 alt2">
</div>
<div class="line number38 index37 alt1">
</div>
<div class="line number39 index38 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number40 index39 alt1">
<code class="js plain">< / scr ipt></code><span style="font-family: arial,helvetica,sans-serif; font-size: x-small;"> </span></div>
<div class="line number40 index39 alt1">
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;"> </span><code class="js plain">< in put ty pe=</code><code class="js string">"button"</code> <code class="js plain">value=</code><code class="js string">"Hello"</code> <code class="js plain">id=</code><code class="js string">"btnhello"</code> <code class="js plain">/ ></code></div>
<h4 style="text-align: left;">
<span style="font-size: small;"><span style="font-weight: normal;"><span style="font-family: arial,helvetica,sans-serif;"> </span></span></span></h4>
<h4 style="text-align: left;">
<span style="font-size: small;"><span style="font-weight: normal;"><span style="font-family: arial,helvetica,sans-serif;"> Thank you for visiting my blog.</span></span></span></h4>
<h4 style="text-align: left;">
<span style="font-size: small;"><span style="font-weight: normal;"><span style="font-family: arial,helvetica,sans-serif;"> </span></span></span></h4>
</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-59756970574218278582013-12-16T18:41:00.000+05:302014-03-25T09:35:49.081+05:30Mobile App development with PhoneGap<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">[Original Post from my blog <a href="http://onlyms.net/">OnlyMS.Net</a>] </span><br />
<br />
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">I
am now starting to get into mobile app development and to start mobile
app development using a suitable tool, I choose PhoneGap. I choose
PhoneGap because to develop mobile app using PhoneGap I do not need to
learn anything new as I know HTML, JavaScript, CSS and these things are
using here to develop any mobile app for iOS, Android, Windows,
Blackberry, Bada etc mobile OS.</span><br />
<br />
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">To start PhoneGap first install node.js from <a href="http://nodejs.org/">here. </a></span><br />
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">Next go to command line in your windows and type following (link <a href="http://phonegap.com/install/">here</a>)</span><br />
<pre><code>C:\> npm install -g phonegap
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">It will start installing the software.</span>
<span style="font-family: arial,helvetica,sans-serif; font-size: x-small;">Read full learning from <a href="http://docs.phonegap.com/en/3.2.0/index.html">here </a>and can read basic stuff from <a href="http://phonegap.com/blog/build/getting-started-with-phonegap-and-phonegap-build/">here</a>.</span></code></pre>
</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-84230208650902489202013-11-26T23:42:00.000+05:302014-03-25T09:36:00.475+05:30jQuery Ajax: Create HTML Table with User details at Client based on Server Data<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial;">[<b>This post initially posted on my MS Technical blog <a href="http://onlyms.net/post/2013/11/26/jQuery-Ajax-Create-HTML-Table-with-User-details-at-Client-based-on-Server-Data" target="_blank">here</a>. Visit <a href="http://onlyms.net/">http://onlyms.net</a> for better readability</b>]. </span><br />
<span style="font-family: Arial;"><br /></span>
<span style="font-family: Arial;">I am sharing information on JQuery-AJAX on ASP.Net in incremental
order to learn it properly. In last post on this topic I shared information
about how to change some HTML control based on server data using jQuery. Now I
shall share information how to create a user data list or table with some data
which is coming from server. Here I am taking example of some user data with
one image. In my project I am using one sample JPG image with IMG folder in
project (available in<span class="apple-converted-space"> </span><a href="http://onlyms.net/post/2013/11/01/jQuery-JSON-AJAX-ASPNet-C1" target="_blank">1st post attached project on that topic</a>).<span class="apple-converted-space"> </span></span><span style="font-family: Arial; font-size: 13.5pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<br /></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial;">Step 1: Create back-end server code to provide data. Look
carefully at below server code to prepare a web-service [webmethod] method.</span><span style="font-family: Arial; font-size: 13.5pt;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<br /></div>
<div class="container">
<blockquote class="tr_bq">
<code class="c-sharp plain">[WebMethod]</code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">static</code> <code class="c-sharp keyword">string</code> <code class="c-sharp plain">CreateUserList()</code><code class="c-sharp plain">{</code><code class="c-sharp spaces"> </code><code class="c-sharp plain">List<</code><code class="c-sharp keyword">object</code><code class="c-sharp plain">> user = </code><code class="c-sharp keyword">new</code> <code class="c-sharp plain">List<</code><code class="c-sharp keyword">object</code><code class="c-sharp plain">>();</code><code class="c-sharp spaces"> </code><code class="c-sharp plain">user.Add(</code><code class="c-sharp keyword">new</code> <code class="c-sharp plain">{ Id = </code><code class="c-sharp string">"10"</code><code class="c-sharp plain">, Name = </code><code class="c-sharp string">"A"</code><code class="c-sharp plain">, Image = </code><code class="c-sharp string">"img/sample.jpg"</code> <code class="c-sharp plain">});</code><code class="c-sharp spaces"> </code><code class="c-sharp plain">user.Add(</code><code class="c-sharp keyword">new</code> <code class="c-sharp plain">{ Id = </code><code class="c-sharp string">"20"</code><code class="c-sharp plain">, Name = </code><code class="c-sharp string">"B"</code><code class="c-sharp plain">, Image = </code><code class="c-sharp string">"img/sample.jpg"</code> <code class="c-sharp plain">});</code><code class="c-sharp spaces"> </code><code class="c-sharp plain">user.Add(</code><code class="c-sharp keyword">new</code> <code class="c-sharp plain">{ Id = </code><code class="c-sharp string">"30"</code><code class="c-sharp plain">, Name = </code><code class="c-sharp string">"C"</code><code class="c-sharp plain">, Image = </code><code class="c-sharp string">"img/sample.jpg"</code> <code class="c-sharp plain">});</code><code class="c-sharp spaces"> </code><code class="c-sharp plain">user.Add(</code><code class="c-sharp keyword">new</code> <code class="c-sharp plain">{ Id = </code><code class="c-sharp string">"40"</code><code class="c-sharp plain">, Name = </code><code class="c-sharp string">"D"</code><code class="c-sharp plain">, Image = </code><code class="c-sharp string">"img/sample.jpg"</code> <code class="c-sharp plain">});</code><br />
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">return</code> <code class="c-sharp plain">(</code><code class="c-sharp keyword">new</code> <code class="c-sharp plain">JavaScriptSerializer().Serialize(user));<br /> </code><code class="c-sharp plain">}</code></blockquote>
<div class="line number11 index10 alt2">
<div class="MsoNormal">
<span style="font-family: Arial;">In the above
code I am creating a List object with property ID, Name and Image. For my case
ID and Name is different but all are same image. In real life project you can
change it with some different image name. I am adding these user data into List
object and finally I am<span class="apple-converted-space"> </span></span><b><span style="font-family: Arial;">serializing the array/list to send it to
client as JSON data format</span></b>.
Using below line of code:<span style="font-family: Arial;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="container">
<blockquote class="tr_bq">
<code class="c-sharp keyword">return</code> <code class="c-sharp plain">(</code><code class="c-sharp keyword">new</code> <code class="c-sharp plain">JavaScriptSerializer().Serialize(user));</code></blockquote>
</div>
<div class="MsoNormal">
<span style="font-family: Arial;">Step 2: Prepare HTML section
as below:<o:p></o:p></span></div>
<div class="container">
<blockquote class="tr_bq">
<code class="js plain">< fo rm id=</code><code class="js string">"form1"</code> <code class="js plain">runat=</code><code class="js string">"server"</code><code class="js plain">></code><code class="js spaces"> </code><code class="js plain"><di v=""><br /></di></code><code class="js spaces"> </code><code class="js plain"><h 3="">jQuery Ajax: Create HTML Table </h></code><code class="js keyword">with</code> <code class="js plain">User details at client based on server data.</code></blockquote>
</div>
</div>
</div>
<br />
<br />
<code class="js spaces"> </code><code class="js plain"><br /></code><code class="js spaces"> </code><code class="js plain">< t able id=</code><code class="js string">"tblList"</code><code class="js plain">></code><br />
<code class="js spaces"> </code><code class="js plain"><br /></code><code class="js spaces"> </code><code class="js plain"><in id="</code" put=""><code class="js string">"btnClick"</code> <code class="js plain">type=</code><code class="js string">"button"</code> <code class="js plain">value=</code><code class="js string">"Click Me!"</code> <code class="js plain">/></code><code class="js spaces"> </code><code class="js plain"></code></in></code><br />
<code class="js plain"></code><br />
<div class="line number11 index10 alt2">
<code class="c-sharp plain"><span style="font-family: Arial;">In this HTML code I have declared a HTML
Table where I shall append rows to design a table with server provided user
data. The button will be used to invoke server method using JQuery. HTML
section is extremely easy and simple.<o:p></o:p></span><br />
<br />
<span style="font-family: Arial;">Step 3: Invoke server webmethod/web service
using JQuery AJAX. <o:p></o:p></span><br />
</code><br />
<div class="MsoNormal">
<code class="c-sharp plain"><br /></code></div>
<code class="c-sharp plain">
</code>
<br />
<div class="container">
<blockquote class="tr_bq">
<code class="c-sharp plain"><code class="js plain"><he ad="" runat="</code"><code class="js string">"server"</code><code class="js plain">></code><code class="js plain"><title></title><br /></code><code class="js plain"><sc ript="" src="</code"><code class="js string">"js/jquery-1.9.1.js"</code><code class="js plain">></code></sc></code></he></code></code></blockquote>
</div>
<code class="c-sharp plain">
</code></div>
<br />
<code class="js plain">< scr ipt type=</code><code class="js string">"text/javasc ript"</code><code class="js plain">></code><code class="js spaces"> </code><code class="js plain">$(document).ready(</code><code class="js keyword">function</code> <code class="js plain">() {</code><br />
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#btnClick"</code><code class="js plain">).click(</code><code class="js keyword">function</code> <code class="js plain">() {</code><br />
<code class="js spaces"> </code><code class="js plain">$.ajax({</code><code class="js spaces"> </code><code class="js plain">type: </code><code class="js string">"POST"</code><code class="js plain">,</code><code class="js spaces"> </code><code class="js plain">url: </code><code class="js string">"ArrayToList.aspx/CreateUserList"</code><code class="js plain">, <br /> </code><code class="js spaces"> </code><code class="js plain">contentType: </code><code class="js string">"application/json; charset=utf-8"</code><code class="js plain">,</code><code class="js spaces"> </code><code class="js plain">dataType: </code><code class="js string">"json"</code><code class="js plain">,</code><br />
<code class="js spaces"> </code><code class="js plain">success: </code><code class="js keyword">function</code> <code class="js plain">(msg) {</code><br />
<code class="js spaces"> </code><code class="js keyword">var</code> <code class="js plain">user = eval(msg.d);</code><code class="js spaces"> </code><code class="js plain">$.each(user, </code><code class="js keyword">function</code> <code class="js plain">() {</code><code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#tb lList"</code><code class="js plain">).app end(</code><code class="js string">"
</code><br />
<code class="js string">User Id: "</code><br />
<code class="js string">
</code> <code class="js plain">+ </code><code class="js keyword">thi s</code><code class="js plain">.Id + </code><code class="js string">",</code>Name:"<br />
<code class="js plain">+ </code><code class="js keyword">this</code><code class="js plain">.Name + </code><code class="js string">"</code><a href="http://www.blogger.com/blogger.g?blogID=4193683792173214666#" ti="" tle="">< i m g al t= '' hei ght ='100' sr c='"</a><br />
<code class="js plain">+ </code><code class="js keyword">this</code><code class="js plain">.Image + </code><code class="js string">"' /></code></ t r>"<code class="js plain">);</code><code class="js spaces"> </code><code class="js plain">});</code><code class="js spaces"> </code><code class="js plain">}</code><code class="js spaces"> </code><code class="js plain">});</code><code class="js spaces"> </code><code class="js plain">});</code><code class="js spaces"> </code><code class="js plain">});</code><code class="js plain"></code><br />
<code class="js plain"></ he ad></code><br />
<div class="line number11 index10 alt2">
<code class="c-sharp plain"><br /></code></div>
Here I am coping full HEAD section where I have called JQuery 1.9.1 and then have written JQuery code (to know more about these part on each step by step from <a href="http://onlyms.net/post/2013/11/01/jQuery-JSON-AJAX-ASPNet-C1#comment">here</a>). Here I am calling 'CreateUserList' web method and on successful AJAX call 'Success:' will executed where main table design will performed.<br />
All JSON data will come at client as serialized and it will be parsed by eval() method based on message's properly. Next it will start looping with 'each' method will concatenate string with column value like 'this.Id','this.Name','this.Image'. Here need to note that Id, Name and Image was the column/parameter name in List. Finally this concatenated string is adding or appending at as row in declared table.<br />
<span style="font-family: Arial; font-size: x-small;"><br /></span>
<span style="font-family: Arial; font-size: x-small;">The whole thing will look like below image in browser.</span><br />
<span style="font-family: Arial; font-size: x-small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkX8HbKCkw94QUxqFieXEI_42iPMC8R1izQbRS7ewx2i1cDLMXRo_HFCa40drBcs3kLB4vwelxKQHGrLQ1tRg8ofe0swNI-OKIWrjRxa8wEBzsGxKj0M52LgL9VvAjIe3ANaOPzdrpiPg/s1600/ArrayToList.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkX8HbKCkw94QUxqFieXEI_42iPMC8R1izQbRS7ewx2i1cDLMXRo_HFCa40drBcs3kLB4vwelxKQHGrLQ1tRg8ofe0swNI-OKIWrjRxa8wEBzsGxKj0M52LgL9VvAjIe3ANaOPzdrpiPg/s400/ArrayToList.jpg" height="337" width="400" /></a></div>
<span style="font-family: Arial; font-size: x-small;"><br /></span>
Get source code from below attached files.<br />
Thank you for reading my blow, please comeback again for next post, how to create a user search list as like facebook.</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-19817210416338732013-11-16T20:52:00.000+05:302014-03-25T09:36:29.904+05:30JQuery-AJAX: Change a HTML control name from server<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I want to share a very basic and simple but a bit advance sample code
on ASP.Net Ajax using JSON and JQuery. Now I want to change a control
name or text based on server response data.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">To demonstrate this thing I shall change my clicked button name based
on server. This type of sample code is very easy to learn and you can
use similar concept to develop solution for lots of requirement. Say you
are developing some code where you have a button to 'Like' but after
clicking on it the button name will change to 'Unlike', or in a social
network one user will start following some group or person; so when user
will click on 'Follow' button will be changed to 'Following' etc.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Lets have a look in to the code:</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">HTML for this solution as below -</span><br />
<blockquote class="tr_bq">
<code class="js plain">in put id=</code><code class="js string">"btnClick"</code> <code class="js plain">type=</code><code class="js string">"button"</code> <code class="js plain">value=</code><code class="js string">"Click Me!"</code><br />
<code class="js spaces"></code><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Here button 'btnClick' text will be changed. Next look into the back-end C# code.</span><code class="js string"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></code>
<code class="js string"></code><br />
<br /></blockquote>
<div class="container">
<blockquote>
<div class="line number1 index0 alt2">
<code class="c-sharp plain">[WebMethod]</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp keyword">public</code> <code class="c-sharp keyword">static</code> <code class="c-sharp keyword">string</code> <code class="c-sharp plain">ChangeButtonNameJQuery(</code><code class="c-sharp keyword">string</code> <code class="c-sharp plain">btnName)</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp plain">{ </code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">return</code> <code class="c-sharp plain">btnName+ </code><code class="c-sharp string">" - changed from Server"</code><code class="c-sharp plain">;</code></div>
<div class="line number5 index4 alt2">
<code class="c-sharp plain">}</code></div>
</blockquote>
<div class="line number5 index4 alt2">
<code class="c-sharp plain"><br /></code></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /><br />Very simple Web Method or WebService in page 'ChangeButtonName.aspx'. To declare a page method as WebService we need to use namespace 'System.Web.Services', which I have used in using namespace section. Besure this method is 'static' type and its 'public'. Return type of webservice is string and invoking with one string parameter 'btnName'.<br /> <br /> Now look at the jQuery code.<br /> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="container">
<blockquote class="tr_bq">
<div class="line number1 index0 alt2">
<code class="js plain"><sc ript="" src="</code"><code class="js string">"js/jquery-1.9.1.js"</code><code class="js plain">></code></sc></code></div>
<div class="line number2 index1 alt1">
<code class="js plain"><sc ript="" type="</code"><code class="js string">"text/javascript"</code><code class="js plain">></code></sc></code></div>
<div class="line number3 index2 alt2">
<code class="js spaces"> </code><code class="js plain">$(document).ready(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div>
<div class="line number4 index3 alt1">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#btnClick"</code><code class="js plain">).click(</code><code class="js keyword">function</code> <code class="js plain">() { </code></div>
<div class="line number5 index4 alt2">
<code class="js spaces"> </code> </div>
<div class="line number6 index5 alt1">
<code class="js spaces"> </code><code class="js plain">$.ajax({</code></div>
<div class="line number7 index6 alt2">
<code class="js spaces"> </code><code class="js plain">type: </code><code class="js string">"POST"</code><code class="js plain">,</code></div>
<div class="line number8 index7 alt1">
<code class="js spaces"> </code><code class="js plain">url: </code><code class="js string">"ChangeButtonName.aspx/ChangeButtonNameJQuery"</code><code class="js plain">,</code></div>
<div class="line number9 index8 alt2">
<code class="js spaces"> </code><code class="js plain">data: JSON.stringify({ btnName: $(</code><code class="js string">"#btnClick"</code><code class="js plain">).val() }),</code></div>
<div class="line number10 index9 alt1">
<code class="js spaces"> </code><code class="js plain">contentType: </code><code class="js string">"application/json; charset=utf-8"</code><code class="js plain">,</code></div>
<div class="line number11 index10 alt2">
<code class="js spaces"> </code><code class="js plain">dataType: </code><code class="js string">"json"</code><code class="js plain">,</code></div>
<div class="line number13 index12 alt2">
<code class="js spaces"> </code><code class="js plain">success: </code><code class="js keyword">function</code> <code class="js plain">(msg) { </code></div>
<div class="line number14 index13 alt1">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#btnClick"</code><code class="js plain">).val(msg.d); </code></div>
<div class="line number15 index14 alt2">
<code class="js spaces"> </code><code class="js plain">}</code></div>
<div class="line number16 index15 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number17 index16 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number18 index17 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
</blockquote>
<div class="line number19 index18 alt2">
<code class="js plain"></code></div>
</div>
</div>
<div class="container">
<div class="line number1 index0 alt2">
<code class="js plain"><script src="</code"><code class="js string">"js/jquery-1.9.1.js"</code><code class="js plain">></script></code></div>
<div class="line number2 index1 alt1">
<code class="js plain"><script type="</code"><code class="js string">"text/javascript"</code><code class="js plain">></code></div>
<div class="line number3 index2 alt2">
<code class="js spaces"> </code><code class="js plain">$(document).ready(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div>
<div class="line number4 index3 alt1">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#btnClick"</code><code class="js plain">).click(</code><code class="js keyword">function</code> <code class="js plain">() { </code></div>
<div class="line number5 index4 alt2">
<code class="js spaces"> </code> </div>
<div class="line number6 index5 alt1">
<code class="js spaces"> </code><code class="js plain">$.ajax({</code></div>
<div class="line number7 index6 alt2">
<code class="js spaces"> </code><code class="js plain">type: </code><code class="js string">"POST"</code><code class="js plain">,</code></div>
<div class="line number8 index7 alt1">
<code class="js spaces"> </code><code class="js plain">url: </code><code class="js string">"ChangeButtonName.aspx/ChangeButtonNameJQuery"</code><code class="js plain">,</code></div>
<div class="line number9 index8 alt2">
<code class="js spaces"> </code><code class="js plain">data: JSON.stringify({ btnName: $(</code><code class="js string">"#btnClick"</code><code class="js plain">).val() }),</code></div>
<div class="line number10 index9 alt1">
<code class="js spaces"> </code><code class="js plain">contentType: </code><code class="js string">"application/json; charset=utf-8"</code><code class="js plain">,</code></div>
<div class="line number11 index10 alt2">
<code class="js spaces"> </code><code class="js plain">dataType: </code><code class="js string">"json"</code><code class="js plain">,</code></div>
<div class="line number12 index11 alt1">
</div>
<div class="line number13 index12 alt2">
<code class="js spaces"> </code><code class="js plain">success: </code><code class="js keyword">function</code> <code class="js plain">(msg) { </code></div>
<div class="line number14 index13 alt1">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#btnClick"</code><code class="js plain">).val(msg.d); </code></div>
<div class="line number15 index14 alt2">
<code class="js spaces"> </code><code class="js plain">}</code></div>
<div class="line number16 index15 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number17 index16 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number18 index17 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number19 index18 alt2">
<code class="js plain"></script></code></div>
</div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br />I have used here Jquery version 1.9.1 and calling my method when document becomes ready to execute which will call just after loading completion of page.</span><br />
<code class="js string"><br /></code>
<code class="js string"></code><br />
<div class="container">
<blockquote class="tr_bq">
<div class="line number1 index0 alt2">
<code class="js plain">$(document).ready(</code><code class="js keyword">function</code> <code class="js plain">() </code></div>
<div class="line number2 index1 alt1">
<code class="js plain">{</code></div>
<div class="line number3 index2 alt2">
<code class="js plain">}</code></div>
</blockquote>
<div class="line number3 index2 alt2">
<code class="js plain"><br /></code></div>
<span style="font-family: Arial, Helvetica, sans-serif;">the above code is doing this thing (<a href="http://onlyms.net/post/2013/11/01/jQuery-JSON-AJAX-ASPNet-C1">to know details about Jquery Ajax calling from ASP.Net, read my 1st post on Jquery-Ajax</a>). In my present code We are calling web method 'ChangeButtonNameJQuery' from current page (ChangeButtonName.aspx/ChangeButtonNameJQuery). Once successful web method execution client browser is getting response and invoking method 'success:' with response in object 'msg'. We can access server response from 'msg' property 'd' by using 'msg.d' and that I am setting to change button value, by</span><br />
<div class="line number3 index2 alt2">
<code class="js plain"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></code></div>
</div>
<blockquote class="tr_bq">
<code class="js string"></code><br /></blockquote>
<div class="container">
<blockquote>
<div class="line number1 index0 alt2">
<code class="js plain">$(</code><code class="js string">"#btnClick"</code><code class="js plain">).val(msg.d);</code></div>
</blockquote>
<div class="line number1 index0 alt2">
<code class="js plain"><br /></code></div>
<span style="font-family: Arial, Helvetica, sans-serif;">I hope you have enjoyed this post and has helped to learn little more on ASP.Net ajax using JQuery. Continue reading my next blog post to know more on Ajax using JQuery.</span></div>
<div class="container">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /> Thank you for visiting my blog. Happy coding.</span></div>
</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-54228924833621307372013-11-13T00:24:00.001+05:302014-03-25T09:38:27.381+05:30JQuery-AJAX:Pass two parameters and concatenate two string at server side with ASP.Net<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://onlyms.net/category/jQuery-AJAX-in-ASPNet" target="_blank">[Original Post from my another blog] </a>- visit it for better design and reading friendly.<br />
<br />
<div style="text-align: left;">
This is advance article of my previous post on JQuery-AJAX in ASP.Net <a href="http://onlyms.net/category/jQuery-AJAX-in-ASPNet">JQuery-AJAX: Get Server Time using jQuery AJAX in ASP.Net.</a>
In earlier post I have describe how to get server time using ASP.Net
with Jquery ajax technology. How I shall describe little bit advance
things, that is how to pass two parameter from client and catch these
values in server then concatenate in server and response result to
client to show it.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Step 1: As previous declare a webmethod or webservice at backend.</div>
<div style="text-align: left;">
<br /></div>
<div class="container">
<div class="line number1 index0 alt2">
<code class="c-sharp plain">[WebMethod]</code></div>
<div class="line number2 index1 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">public</code> <code class="c-sharp keyword">static</code> <code class="c-sharp keyword">string</code> <code class="c-sharp plain">ConcateName(</code><code class="c-sharp keyword">string</code> <code class="c-sharp plain">fname,</code><code class="c-sharp keyword">string</code> <code class="c-sharp plain">lname)</code></div>
<div class="line number3 index2 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">{</code></div>
<div class="line number4 index3 alt1">
<code class="c-sharp spaces"> </code><code class="c-sharp keyword">return</code> <code class="c-sharp plain">fname +</code><code class="c-sharp string">" "</code><code class="c-sharp plain">+lname;</code></div>
<div class="line number5 index4 alt2">
<code class="c-sharp spaces"> </code><code class="c-sharp plain">}</code></div>
</div>
<div style="text-align: left;">
<br /></div>
Note here I have passed two parameter with name 'fnale' and 'lname'.
In JQuery you have to invoke method with exactly same name of parameter
otherwise code will not run.<br />
<br />
Step 2: Declare HTML control, tow text box, a button and a DIV to show server response. (visit my <a href="http://onlyms.net/category/jQuery-AJAX-in-ASPNet" target="_blank">primary blog</a> for better view of HTML and JQuery).<br />
<br />
<div class="container">
<div class="line number1 index0 alt2">
<code class="js plain">For 'First Name' input HTML id=</code><code class="js string">"txtFName"</code> <code class="js plain">type=</code><code class="js string">"text"</code><code>. </code></div>
<div class="line number2 index1 alt1">
<code class="js plain">Last Name: input id=</code><code class="js string">"txtLName"</code> <code class="js plain">type=</code><code class="js string">"text"</code> <code class="js plain">and a button. </code></div>
<div class="line number3 index2 alt2">
<code>with</code><code class="js plain"> id=</code><code class="js string">"btnClick"</code> <code class="js plain">type=</code><code class="js string">"button"</code> <code class="js plain">value=</code><code class="js string">"Concat Name"</code><code class="js plain">.</code></div>
<div class="line number3 index2 alt2">
</div>
<div class="line number4 index3 alt1">
<code class="js plain">And response in a DIV with id=</code><code class="js string">"dvResponse"</code><code class="js plain">.</code></div>
</div>
<br />
<div style="text-align: left;">
Step 3: Write JQuery code in ASPX page as below:</div>
<div class="container">
<div class="line number1 index0 alt2">
<code class="js plain"><br /></code><code class="js plain"></code></div>
<div class="line number3 index2 alt2">
<code class="js spaces"> </code><code class="js plain">$(document).ready(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div>
<div class="line number4 index3 alt1">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#btnClick"</code><code class="js plain">).click(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div>
<div class="line number5 index4 alt2">
<code class="js spaces"> </code><code class="js comments">//alert($("#txtFName").val());</code></div>
<div class="line number6 index5 alt1">
<code class="js spaces"> </code><code class="js plain">$.ajax({</code></div>
<div class="line number7 index6 alt2">
<code class="js spaces"> </code><code class="js plain">type: </code><code class="js string">"POST"</code><code class="js plain">,</code></div>
<div class="line number8 index7 alt1">
<code class="js spaces"> </code><code class="js plain">url: </code><code class="js string">"ConcatName.aspx/ConcateName"</code><code class="js plain">,</code></div>
<div class="line number9 index8 alt2">
<code class="js spaces"> </code><code class="js plain">data: JSON.stringify({ fname: $(</code><code class="js string">"#txtFName"</code><code class="js plain">).val(), lname:$(</code><code class="js string">"#txtLName"</code><code class="js plain">).val() }),</code></div>
<div class="line number10 index9 alt1">
<code class="js spaces"> </code><code class="js plain">contentType: </code><code class="js string">"application/json; charset=utf-8"</code><code class="js plain">,</code></div>
<div class="line number11 index10 alt2">
<code class="js spaces"> </code><code class="js plain">dataType: </code><code class="js string">"json"</code><code class="js plain">,</code></div>
<div class="line number12 index11 alt1">
<code class="js spaces"> </code><code class="js plain">success: </code><code class="js keyword">function</code> <code class="js plain">(msg) {</code></div>
<div class="line number13 index12 alt2">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#dvResponse"</code><code class="js plain">).append(msg.d+</code><code class="js string">"<br />"</code><code class="js plain">);</code></div>
<div class="line number14 index13 alt1">
<code class="js spaces"> </code><code class="js comments">//$("#dvResponse").html(msg.d);</code></div>
<div class="line number15 index14 alt2">
<code class="js spaces"> </code><code class="js plain">}</code></div>
<div class="line number16 index15 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number17 index16 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number18 index17 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number19 index18 alt2">
<code class="js spaces"> </code><code class="js plain"></code></div>
</div>
</div>
<div class="line number19 index18 alt2">
</div>
<div style="text-align: left;">
Note here most important two lines as below:</div>
<div style="text-align: left;">
<br /></div>
<div class="container">
<div class="line number1 index0 alt2">
<code class="js plain">url: </code><code class="js string">"ConcatName.aspx/ConcateName"</code><code class="js plain">,</code></div>
<div class="line number2 index1 alt1">
<code class="js plain">data: JSON.stringify({ fname: $(</code><code class="js string">"#txtFName"</code><code class="js plain">).val(), lname:$(</code><code class="js string">"#txtLName"</code><code class="js plain">).val() }),</code></div>
</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
First line is describing which WebService should invoke and next line
the parameter for webservice. Note here I have mentioned exactly same
name of WebService parameter.<br />
<br />
When you will run this code and type value in two text box and then
click on button, browser will invoke server WebService and concatenate
two name and then response to server. Which will catch by JQuery ajax
part and result will be shown in DIV 'dvResponse'.<br />
How you have enjoyed my post and it has helped for your learning on JQuery AJAX technology in ASP.Net-C#.</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-49640542621161807962013-11-05T09:11:00.000+05:302014-03-25T09:39:11.611+05:30JQuery-AJAX: Get Server Time using jQuery AJAX in ASP.Net<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0cm;">
[Original post from my blog <a href="http://onlyms.net/post/2013/11/01/jQuery-JSON-AJAX-ASPNet-C1" target="_blank">http://onlyms.net/</a>/]<br />
<br />
Friends, Now I want to share my codes
with on ASP.Net AJAX by using jQuery. Earlier I have worked with
UpdatePanel for AJAX work but it seems to this is not the best approach
however its most easiest and simplest way for AJAX. So when you do not
need maximum performance then definitely you can consider it to save
time. But if you need maximum performance then my recommendation always
jQuery AJAX. I shall share my blog post for AJAX work using jQuery and
JSON with ASP.Net and C# with sample code which will help reader to
learn this technology very easily.</div>
<br />
<div style="margin-bottom: 0cm;">
In my first post I shall show how to get server time using jQuery with AJAX that means without page post back.</div>
<br />
<br />
<div style="margin-bottom: 0cm;">
<b>Step 1:</b> Create a WebService which will response to client to inform server time. WebService as below:</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
using System;</div>
<div style="margin-bottom: 0cm;">
using System.Collections.Generic;</div>
<div style="margin-bottom: 0cm;">
using System.Linq;</div>
<div style="margin-bottom: 0cm;">
using System.Web;</div>
<div style="margin-bottom: 0cm;">
using System.Web.UI;</div>
<div style="margin-bottom: 0cm;">
using System.Web.UI.WebControls;</div>
<div style="margin-bottom: 0cm;">
using System.Web.Services;</div>
<div style="margin-bottom: 0cm;">
public partial class GetTime : System.Web.UI.Page</div>
<div style="margin-bottom: 0cm;">
{</div>
<div style="margin-bottom: 0cm;">
protected void Page_Load(object sender, EventArgs e)</div>
<div style="margin-bottom: 0cm;">
{</div>
<div style="margin-bottom: 0cm;">
}</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[WebMethod]</div>
<div style="margin-bottom: 0cm;">
public static string GetDate()</div>
<div style="margin-bottom: 0cm;">
{</div>
<div style="margin-bottom: 0cm;">
string str="<b>[Response from Webservice] </b><br />
Current Server Time is: "+ DateTime.Now.ToString() + "." + DateTime.Now.Millisecond.ToString();</div>
<div style="margin-bottom: 0cm;">
return str;</div>
<div style="margin-bottom: 0cm;">
} </div>
<div style="margin-bottom: 0cm;">
}</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<pre class="western">Nothing more require at back-end now I shall show at front end part of code.Full back-end code as below:
Note to declare a WebService first we have use namespace '<b>using System.Web.Services;</b>' and then have declared method as '<b>[WebMethod]</b>'
<b>Step 2</b>: Declare a HTML button for clicking and a DIV to show server response.</pre>
<pre class="western"><div class="container">
<div class="line number5 index4 alt2">
<code class="css plain"></code>
<br />
<pre class="western" style="margin-bottom: 0.5cm;"><code class="css plain"><b>Step 3</b>: Set jQuery Part. Here first need to link jquery code which I am using version jquery-1.9.1.js and I have placed at my project at js folder. </code></pre>
<pre class="western" style="margin-bottom: 0.5cm;"><table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr><td class="gutter"><div class="line number1 index0 alt2">
</div>
</td><td class="code"><div class="container">
<div class="line number1 index0 alt2">
<code class="css plain"><script src="</code"><code class="css string">"js/jquery-1.9.1.js"</code><code class="css plain">></script></code></div>
<div class="line number1 index0 alt2">
<code class="css plain">
</code></div>
<div class="line number1 index0 alt2">
<code class="css plain"></code>
<br />
<pre class="western" style="margin-bottom: 0.5cm;"><code class="css plain"><b>Step 4</b>: Write jQuery code to access WebService. First look into the code next I am trying to clarify about these code.</code></pre>
<code class="css plain">
</code>
<br />
<pre class="western" style="margin-bottom: 0.5cm;"><div class="container">
<div class="line number1 index0 alt2">
<code class="css plain"><code class="js plain"><script type="</code"><code class="js string">"text/javascript"</code><code class="js plain">></code></div>
<div class="line number2 index1 alt1">
<code class="js spaces"> </code><code class="js plain">$(document).ready(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div>
<div class="line number3 index2 alt2">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#btGetDate"</code><code class="js plain">).click(</code><code class="js keyword">function</code> <code class="js plain">() { </code></div>
<div class="line number4 index3 alt1">
<code class="js spaces"> </code><code class="js plain">$.ajax({</code></div>
<div class="line number5 index4 alt2">
<code class="js spaces"> </code><code class="js plain">type: </code><code class="js string">"POST"</code><code class="js plain">,</code></div>
<div class="line number6 index5 alt1">
<code class="js spaces"> </code><code class="js plain">url: </code><code class="js string">"GetserverTime.aspx/GetDate"</code><code class="js plain">,</code></div>
<div class="line number7 index6 alt2">
<code class="js spaces"> </code><code class="js plain">data: </code><code class="js string">"{}"</code><code class="js plain">,</code></div>
<div class="line number8 index7 alt1">
<code class="js spaces"> </code><code class="js plain">contentType: </code><code class="js string">"application/json; charset=utf-8"</code><code class="js plain">,</code></div>
<div class="line number9 index8 alt2">
<code class="js spaces"> </code><code class="js plain">dataType: </code><code class="js string">"json"</code><code class="js plain">,</code></div>
<div class="line number10 index9 alt1">
<code class="js spaces"> </code><code class="js plain">success: </code><code class="js keyword">function</code> <code class="js plain">(msg) { </code></div>
<div class="line number11 index10 alt2">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#dvDate"</code><code class="js plain">).html(msg.d );</code></div>
<div class="line number12 index11 alt1">
<code class="js spaces"> </code><code class="js plain">}</code></div>
<div class="line number13 index12 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number14 index13 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number15 index14 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number16 index15 alt1">
<code class="js plain"></script></code></code></div>
</div>
<code class="css plain"><div class="container">
<div class="line number1 index0 alt2">
JavaScript Script as below:</div>
<div class="line number1 index0 alt2">
</div>
<div class="line number2 index1 alt1">
<code class="js spaces"> </code><code class="js plain">$(document).ready(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div>
<div class="line number3 index2 alt2">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#btGetDate"</code><code class="js plain">).click(</code><code class="js keyword">function</code> <code class="js plain">() { </code></div>
<div class="line number4 index3 alt1">
<code class="js spaces"> </code><code class="js plain">$.ajax({</code></div>
<div class="line number5 index4 alt2">
<code class="js spaces"> </code><code class="js plain">type: </code><code class="js string">"POST"</code><code class="js plain">,</code></div>
<div class="line number6 index5 alt1">
<code class="js spaces"> </code><code class="js plain">url: </code><code class="js string">"GetserverTime.aspx/GetDate"</code><code class="js plain">,</code></div>
<div class="line number7 index6 alt2">
<code class="js spaces"> </code><code class="js plain">data: </code><code class="js string">"{}"</code><code class="js plain">,</code></div>
<div class="line number8 index7 alt1">
<code class="js spaces"> </code><code class="js plain">contentType: </code><code class="js string">"application/json; charset=utf-8"</code><code class="js plain">,</code></div>
<div class="line number9 index8 alt2">
<code class="js spaces"> </code><code class="js plain">dataType: </code><code class="js string">"json"</code><code class="js plain">,</code></div>
<div class="line number10 index9 alt1">
<code class="js spaces"> </code><code class="js plain">success: </code><code class="js keyword">function</code> <code class="js plain">(msg) { </code></div>
<div class="line number11 index10 alt2">
<code class="js spaces"> </code><code class="js plain">$(</code><code class="js string">"#dvDate"</code><code class="js plain">).html(msg.d );</code></div>
<div class="line number12 index11 alt1">
<code class="js spaces"> </code><code class="js plain">}</code></div>
<div class="line number13 index12 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number14 index13 alt1">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number15 index14 alt2">
<code class="js spaces"> </code><code class="js plain">});</code></div>
<div class="line number16 index15 alt1">
</div>
<div class="line number16 index15 alt1">
<code class="js plain">
</code></div>
</div>
This code will be activated when document becomes ready and when we will
click on button 'btnGetDate' these next code will start execution using
AJAX technology. Its sever calling type will be 'POST' and it will try
to invoke 'GetDate' webservice will has created under
'GetserverTime.aspx' page and it's type will be JSON as describe next
line.Once server response will receive successfully this code will go
for next section 'success:function...' and jQuery will set server
response at our declared DIV element 'dvDate'. From next post I shall
not mention jQuery AJAX declaration in so detail and will discuss on
main section only. Server response will show like below screenshot:<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifUt-PO0SMUtOkS6acvjjYUkwxMbXZCrav-VStH3fuu8EOurvwTQ39hzqByFPWr6DiIctbqGJv9p2_Y8sjBM6Mb-wpg5CeJxRmFKDMc0H_aJclsIHm2oBjgjmOMcnPOHxSxSqischq4CM/s1600/picture1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifUt-PO0SMUtOkS6acvjjYUkwxMbXZCrav-VStH3fuu8EOurvwTQ39hzqByFPWr6DiIctbqGJv9p2_Y8sjBM6Mb-wpg5CeJxRmFKDMc0H_aJclsIHm2oBjgjmOMcnPOHxSxSqischq4CM/s1600/picture1.jpg" /></a></div>
</code></pre>
<div class="separator" style="clear: both; text-align: center;">
</div>
<pre class="western" style="margin-bottom: 0.5cm;"><code class="css plain">
</code></pre>
<pre class="western" style="margin-bottom: 0.5cm;"><code class="css plain">Get full source code with better alignment of blog from my blog.</code></pre>
<code class="css plain">
</code></div>
</div>
</td></tr>
</tbody></table>
<code class="css plain">
</code></pre>
<code class="css plain">
</code></div>
</div>
</pre>
</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-59446162811946327472013-08-04T23:46:00.003+05:302014-03-25T09:39:11.614+05:30Lossless Image Compression in C#.Net and VB.Net<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">Last time I shared C# code which can resize an image with desired size
by keeping same Height vs. Width ratio. Now I am going to share next step of
image processing code, which can compress an image without (almost) losing it
quality. </span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">Usually an image which you may have taken from one 10 Mega pixel digital
camera generates image around 5MB file size. To store same size in webserver
and showing it in user’s desktop will slowdown users website browsing
experience. For that reason now all website especially photo sharing and social
network websites, like facebook.com or google plus etc. compress these images
in smaller file size without losing image quality and store in webserver. This
technique saves webserver storage and saves network bandwidth when user opens
these.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">Here I am sharing one method which has written in C# and VB.Net code
(base code found somewhere in google then I updated as I need). This method can
invoke by just one single line of code and can get compressed image.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;"><br /></span></div>
<h4>
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">How can I use this code in my
application?</span></b></h4>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">To use/invoke this method:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<blockquote class="tr_bq">
<span style="color: #002060; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-GB;">CompressJPEGImage(Bitmap
Image, Image Name With Full Path)</span></blockquote>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">To use this method you need to create an object of the class where you
will define this method and then need call it with parameters ‘image object’
and ‘image full name with path’ where compressed will be saved. On successful
compression this method will return 'true' else 'false'.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">In my application I have written two overload methods to save the
compress image and sometimes to get compressed image object as a return of the
method as based on my requirement. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<h3 style="text-align: left;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Full code in C#.Net as below:</span></b></h3>
<h4 style="text-align: left;">
<span style="color: blue; font-family: 'Courier New'; font-size: 9pt;">public bool CompressJPEGImage(Bitmap bmp1,
string tempImgNameWithPath)</span></h4>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> {</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;">
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<br /></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> // for the
Quality parameter category.</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;">
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Quality;</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<br /></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> EncoderParameters
myEncoderParameters = new EncoderParameters(1);</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;">
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 75L);</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;">
myEncoderParameters.Param[0] = myEncoderParameter;</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> try</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> {</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;">
bmp1.Save(tempImgNameWithPath, jgpEncoder, myEncoderParameters);</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;">
return true;</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> }</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> catch
(Exception)</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> {</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;">
return false;</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> }</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 9.0pt;"> }</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
</div>
<h3 style="text-align: left;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Full code in VB.Net as below:</span></b></h3>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<pre class="brush:vbnet" id="code-result"><span style="color: blue;">Public Function CompressJPEGImage(bmp1 As Bitmap, tempImgNameWithPath As String) As Boolean
Dim jgpEncoder As ImageCodecInfo = GetEncoder(ImageFormat.Jpeg)
' for the Quality parameter category.
Dim myEncoder As System.Drawing.Imaging.Encoder = System.Drawing.Imaging.Encoder.Quality
Dim myEncoderParameters As New EncoderParameters(1)
Dim myEncoderParameter As New EncoderParameter(myEncoder, 75L)
myEncoderParameters.Param(0) = myEncoderParameter
Try
bmp1.Save(tempImgNameWithPath, jgpEncoder, myEncoderParameters)
Return True
Catch generatedExceptionName As Exception
Return False
End Try
End Function</span></pre>
<pre class="brush:vbnet" id="code-result"></pre>
<pre class="brush:vbnet" id="code-result"></pre>
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">How can I change image quality and generated size based on my
requirement?<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">For my application I have compressed 75% (75L) but you can change it as
per your requirement. If you increase this value then file size and image
quality both will increase. Run this code with different parameter value and
get image as per your requirement.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="tr_bq">
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">Thanks for reading my blog I hope this code will help you to write code.<o:p></o:p></span></div>
</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-46152682028368935922013-07-28T16:05:00.004+05:302014-12-05T15:35:05.513+05:30Lossless image resize in C# by keeping same aspect ratio.<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
</h2>
<div class="MsoNormal" style="text-align: left;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Now I am developing an image sharing and Indian social
network application (<a href="http://www.alap.me/">www.Alap.Me</a>) where I need
to resize image (JPG for my case). This is a very common situation to all coders
and it helps us if we get some readymade method which can serve our purpose. I
found basic code of this somewhere from Google and later I modified it as I need
and finally developed this code.<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: left;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">This code can resize any image by keeping aspect ratio,
so your image always will be same in width vs. height ratio. <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"><br /></span></div>
<h3 style="text-align: left;">
<b>How to use it?</b></h3>
<div class="MsoNormal">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"><br /></span></b></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">This is very easy to use this code; just you need to call
it with image file name with full path and maximum height and width. My code
automatically detects height or width, which is maximum at your parameter and
based on this, code will set another parameter based on aspect ratio and
finally resize your image.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"><br /></span></div>
<blockquote class="tr_bq">
<span style="background: white; color: #376092; font-family: "Comic Sans MS"; font-size: 9.5pt; line-height: 115%; mso-bidi-font-family: Consolas; mso-highlight: white; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-color: #376092; mso-style-textfill-fill-colortransforms: lumm=75000; mso-style-textfill-fill-themecolor: accent1; mso-themecolor: accent1; mso-themeshade: 191;">ResizeImage(fileLocationWithName,
maxWidth, maxHeight);</span></blockquote>
<div class="MsoNormal">
<h3 style="text-align: left;">
<span style="font-family: "Arial","sans-serif";"><b>Complete Code in C#.Net</b></span></h3>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> <span class="apple-converted-space"> </span>public<span class="apple-converted-space"> </span>Bitmap<span class="apple-converted-space"> </span>ResizeImage(string<span class="apple-converted-space"> </span>fileNameWithPath,<span class="apple-converted-space"> </span>int<span class="apple-converted-space"> </span>maxWidth,<span class="apple-converted-space"> </span>int<span class="apple-converted-space"> </span>maxHeight)<br />
<u1:p></u1:p> { <span class="apple-converted-space"> </span></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> FileStream<span class="apple-converted-space"> </span>stream =<span class="apple-converted-space"> </span>new<span class="apple-converted-space"> </span>FileStream(fileNameWithPath,<span class="apple-converted-space"> </span>FileMode.Open);<br />
<u1:p></u1:p> <span class="apple-converted-space"> </span>Stream<span class="apple-converted-space"> </span>streamImage = (Stream)stream;<br />
<u1:p></u1:p> <span class="apple-converted-space"> </span>Bitmap<span class="apple-converted-space"> </span>originalImage =<span class="apple-converted-space"> </span>new<span class="apple-converted-space"> </span>Bitmap(streamImage);<br />
<u1:p></u1:p> <span class="apple-converted-space"> </span>int<span class="apple-converted-space"> </span>newWidth
= originalImage.Width;<br />
<u1:p></u1:p> <span class="apple-converted-space"> </span>int<span class="apple-converted-space"> </span>newHeight
= originalImage.Height;<br />
<u1:p></u1:p> <span class="apple-converted-space"> </span>double<span class="apple-converted-space"> </span>aspectRatio = (double)originalImage.Width
/ (double)originalImage.Height;<br />
<u1:p></u1:p><u1:p> </u1:p> <span class="apple-converted-space"> </span>if<span class="apple-converted-space"> </span>(aspectRatio
> 1 && originalImage.Width > maxWidth)<br />
<u1:p></u1:p> { </span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> newWidth = maxWidth;
newHeight = (int)Math.Round(newWidth / aspectRatio);<br />
<u1:p></u1:p> } <span class="apple-converted-space"> </span></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> else<span class="apple-converted-space"> </span></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> if<span class="apple-converted-space"> </span>(aspectRatio <= 1
&& originalImage.Height > maxHeight)<br />
<u1:p></u1:p> { </span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> newHeight = maxHeight;
newWidth = (int)Math.Round(newHeight * aspectRatio);<br />
<u1:p></u1:p> }<u1:p> </u1:p> <span class="apple-converted-space"> </span></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> Bitmap<span class="apple-converted-space"> </span>newImage =<span class="apple-converted-space"> </span>new<span class="apple-converted-space"> </span>Bitmap(originalImage,
newWidth, newHeight);<br /> Graphics<span class="apple-converted-space"> </span>g =<span class="apple-converted-space"> </span>Graphics.FromImage(newImage);<br /> g.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;</span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"><br /> g.DrawImage(originalImage, 0, 0, newImage.Width, newImage.Height);<u1:p> </u1:p> </span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"><br /></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> originalImage.Dispose(); </span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> stream.Close(); </span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"> stream.Dispose();<u1:p> </u1:p> </span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #002060; font-family: "Courier New"; font-size: 9.0pt;"><span class="apple-converted-space"> </span>return<span class="apple-converted-space"> </span>newImage;<br />
<u1:p></u1:p> }<o:p></o:p></span></div>
<br />
<br /></div>
<h3 style="text-align: left;">
Complete code in VB.Net:</h3>
<pre class="brush:vbnet" id="code-result">Public Function ResizeImage(fileNameWithPath As String, maxWidth As Integer, maxHeight As Integer) As Bitmap
Dim stream As New FileStream(fileNameWithPath, FileMode.Open)
Dim streamImage As Stream = DirectCast(stream, Stream)
Dim originalImage As New Bitmap(streamImage)
Dim newWidth As Integer = originalImage.Width
Dim newHeight As Integer = originalImage.Height
Dim aspectRatio As Double = CDbl(originalImage.Width) / CDbl(originalImage.Height)
If aspectRatio > 1 AndAlso originalImage.Width > maxWidth Then
newWidth = maxWidth
newHeight = CInt(Math.Round(newWidth / aspectRatio))
ElseIf aspectRatio <= 1 AndAlso originalImage.Height > maxHeight Then
newHeight = maxHeight
newWidth = CInt(Math.Round(newHeight * aspectRatio))
End If
Dim newImage As New Bitmap(originalImage, newWidth, newHeight)
Dim g As Graphics = Graphics.FromImage(newImage)
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear
g.DrawImage(originalImage, 0, 0, newImage.Width, newImage.Height)
originalImage.Dispose()
stream.Close()
stream.Dispose()
Return newImage
End Function</pre>
<pre class="brush:vbnet" id="code-result"></pre>
I have compressed attached picture by using my code and see here difference.<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZxNnPOYqsWpmdNsOHuLtE8IJz-jZQbzdt5lTeFejI7XqSleSHgD8DY374I-3jXroxKwVRE2hvahovhIp1k2mpET_CAPMoTvYrBmR_dcX6wtUDs8nFrMnFQZ8l4phAsYxd5SxN6Rrzips/s1600/Resized+Image.jpeg" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZxNnPOYqsWpmdNsOHuLtE8IJz-jZQbzdt5lTeFejI7XqSleSHgD8DY374I-3jXroxKwVRE2hvahovhIp1k2mpET_CAPMoTvYrBmR_dcX6wtUDs8nFrMnFQZ8l4phAsYxd5SxN6Rrzips/s400/Resized+Image.jpeg" height="300" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">This is after re-size (around 30KB)</td></tr>
</tbody></table>
<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9CwroceAfyC4lCUR10he6CSLjPiso6h6Q286EXdzdwpxDTdVIXx854lr9UJNtxHCify2erUNcqC_rFTQnK_xUTiPsHlV_4cD2TqGHiII_fMl6jtyAefDeKPtBq46uAHz9akjYyveTcvw/s1600/Original+Image.JPG" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9CwroceAfyC4lCUR10he6CSLjPiso6h6Q286EXdzdwpxDTdVIXx854lr9UJNtxHCify2erUNcqC_rFTQnK_xUTiPsHlV_4cD2TqGHiII_fMl6jtyAefDeKPtBq46uAHz9akjYyveTcvw/s400/Original+Image.JPG" height="300" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">This is original size photo (around 5MB)</td></tr>
</tbody></table>
<br />
<br />
<div class="MsoNormal">
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;">I hope this will help you to make easier your
coding. Thank you for reading my blog.<o:p></o:p></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-XnpOqxnf31t4uhQCaQe4crrxXtmcOTZIRWknWIJnOmlipaJiAjnbVX09ZvmczJbtME8iapqYg765j90LIpl117SZ9DgRhRfUhIDOK3U1vU8YuriOGFJOgPZ2EUAEfQYULLySNEIkKmQ/s1600/download-clear.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-XnpOqxnf31t4uhQCaQe4crrxXtmcOTZIRWknWIJnOmlipaJiAjnbVX09ZvmczJbtME8iapqYg765j90LIpl117SZ9DgRhRfUhIDOK3U1vU8YuriOGFJOgPZ2EUAEfQYULLySNEIkKmQ/s1600/download-clear.PNG" /></a></div>
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;"><br /></span></div>
</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0India20.593684 78.962880000000041-8.5815185000000014 37.654286000000042 49.7688865 120.27147400000004tag:blogger.com,1999:blog-4193683792173214666.post-44527770063301414232013-07-17T18:30:00.002+05:302014-03-19T22:52:01.559+05:30Small File Transfer Client to Client (via Server) using C#.Net socket programming<div dir="ltr" style="text-align: left;" trbidi="on">
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">After long days I am writing this article and this is the
complete package of these all articles about file transfer from one computer to
another. Till now I have shown how to transfer file from client to server or
server to client. But now I am merging these two things and creating one single
application which can send data/file from one client to another client. It
seems data is going directly from one client to another but actually it’s
rotating via Server, I will explain here these things.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">I am planning to stop this article series on Socket
Programming in Desktop using C#.Net here for now and ignoring large file
transfer sample from client to client because now a day is era of Web
Programming. Long ago I tried to write code in web application with socket but
I failed because web and desktop is totally different type of architecture. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">But in HTML5 is very powerful and it has introduced new
thing to develop socket programming on web as well. In HTML5 there has Web
Socket and using Web Socket Micorsoft has created SignalR which will be my next
attraction of discussion. I shall try to explain and shall create multiple
applications including Web Chat, message broadcasting system using these
technologies. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Before going to discuss Client to Client application I
would like to recap earlier two post:</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span></span></span><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">1.</span><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"> <a href="http://socketprogramming.blogspot.com/2007/11/file-transfer-using-c-socket.html" target="_blank">FileTransfer from Client to Server</a> </span></div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span></span></span><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">2. <a href="http://socketprogramming.blogspot.com/2010/01/send-file-from-server-to-client-using-c.html" target="_blank">FileTransfer from Server to Client</a> </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">I am trying to explain how these were working.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"><!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--></span></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
</span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif";"> File Transfer from Client to Server</span></b></div>
<div class="MsoNormal">
<br /></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; margin-left: 7.3pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt;">
<tbody>
<tr style="height: 8.8pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; height: 8.8pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 210.6pt;" valign="top" width="281"><div class="MsoNormal" style="margin-left: -1.9pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Server</span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; height: 8.8pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 226.95pt;" valign="top" width="303"><div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Client</span></b></div>
</td>
</tr>
<tr style="height: 21.35pt; mso-yfti-irow: 1; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; height: 21.35pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 210.6pt;" valign="top" width="281"><div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">1. Server creates an IP End Point and a socket object
then bind socket object with IP end point and sends it to listen mode for
incoming client request.</span><span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;"></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">5. Server
receive client request and accept it. Once connection established, server
create another socket object which will handle this client all requests until
connection ends. Client will be informed internally by TCP about connect success.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">6. Start preparations
to store incoming byte data from client.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">8. Server receives file byte data along with file name
and stores it in byte array.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">9. Server retrieve file name from byte data.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">10. Server opens a binary stream writer with file name
to store byte data in it. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">11. Once file save complete server closes binary stream
writer and server socket objects.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">14 Server program ends here.</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 21.35pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 226.95pt;" valign="top" width="303"><div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">2. Client creates an IP End Point and a socket object. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">3. Prepare byte data from file
which will be sent to server.</span></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">4. Try to connect to
server using client socket by help of IP end point.</span></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">7. Client starts sending
byte data over connected socket.</span></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">12. Once data transfer
complete and server closes socket connection, client also close client socket
object.</span></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">13. Client program work ends
here.</span></div>
</td>
</tr>
</tbody></table>
<br />
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<br />
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif";">File Transfer from Client to Server</span></b></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; margin-left: 5.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt;">
<tbody>
<tr style="height: 17.5pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; height: 17.5pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 214.75pt;" valign="top" width="286"><div class="MsoNormal" style="margin-left: -1.9pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Server</span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; height: 17.5pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 224.7pt;" valign="top" width="300"><div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Client</span></b></div>
</td>
</tr>
<tr style="height: 148.4pt; mso-yfti-irow: 1; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; height: 148.4pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 214.75pt;" valign="top" width="286"><div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">1. Server creates an IP End Point and a socket object
then bind socket object with IP end point and sends it to listen mode for
incoming client request.</span><span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;"></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">4. Server
receive client request and accept it. Once connection established, server
create another socket object which will handle this client all requests until
connection ends. Client will be informed internally by TCP about connect success.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">6.</span><span lang="EN" style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">
</span><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Prepare
byte data from file which will be sent to client.</span></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">7. Server starts sending
byte data over connected socket.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">12. Once data transfer
complete and client closes socket connection, server also close server socket
object.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">13. Server program work ends here.</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 148.4pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 224.7pt;" valign="top" width="300"><div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">2. Client creates an IP End Point and a socket object.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">3. Try to connect to server using client socket by help
of IP end point.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">5. Start preparations
to store incoming byte data from server.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">8. Client receives file byte data along with file name
and stores it in byte array.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">9. Client retrieve file name from byte data.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">10. Client opens a binary stream writer with file name
to store byte data in it. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">11. Once file save complete client closes binary stream
writer and server socket objects.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">14. Client program work ends here.</span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">So from these two tables it’s
clear that in (1) Client to Server data transfer and (2) Server to Client
program server and client is doing just like opposite execution.</span></div>
<br />
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><br />
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves>false</w:TrackMoves>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<br />
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">When we transfer file over
internet one client cannot connect to another directly because maximum client
do not use static/global IP, so they cannot reach over other internet location
directly. So to transfer file from client to client need server help. Server
stays internet with a static IP which is accessible globally. <span style="mso-spacerun: yes;"> </span>We will use server as temporary storage and to
connect other client via server. Overall architecture will be as below:</span></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-fareast-language: EN-GB; mso-no-proof: yes;"><br /></span><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkBlINj3ZQgNxnivEldZZgXxfCSNEeDa85hxE4NVcl35eqV0g_oEdpQam96NgLo8U2pjeQORB5WhO6jjdbBqgl7wyTWIyTNMWH__Cf4sGNUjTjjUQZiH9cxc0DpJKLj2-p1d7rSTLgnH0/s1600/Client+to+Client.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkBlINj3ZQgNxnivEldZZgXxfCSNEeDa85hxE4NVcl35eqV0g_oEdpQam96NgLo8U2pjeQORB5WhO6jjdbBqgl7wyTWIyTNMWH__Cf4sGNUjTjjUQZiH9cxc0DpJKLj2-p1d7rSTLgnH0/s640/Client+to+Client.jpg" height="218" width="400" /></a></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-fareast-language: EN-GB; mso-no-proof: yes;"><br /></span><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"></span></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-fareast-language: EN-GB; mso-no-proof: yes;"><br /></span><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"></span></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">In above picture, Client A
is trying to send file to client B and both are taking help of Server in between
to make connection. Client A and B both are inaccessible from outside internet
because these are may be in DHCP inside a LAN or its IP has generated by some
other local router. So both will connect to server and transfer data. </span></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Now follow below
communication chart to understand how data will be transferred. This chart is
combination of first two chart. </span></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"><!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--></span></div>
<br />
<div class="MsoNormal" style="margin-left: 18.0pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: medium none; height: 1185px; margin-left: 22.3pt; width: 595px;">
<tbody>
<tr style="height: 16.3pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td colspan="3" style="border: solid windowtext 1.0pt; height: 16.3pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 455.25pt;" valign="top" width="607"><div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span>Data Transfer <span style="mso-spacerun: yes;"> -- ></span></span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: Wingdings; font-size: 9.0pt; line-height: 115%; mso-ascii-font-family: Arial; mso-bidi-font-family: Arial; mso-char-type: symbol; mso-hansi-font-family: Arial; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;"></span></span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"> --------------></span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: Wingdings; font-size: 9.0pt; line-height: 115%; mso-ascii-font-family: Arial; mso-bidi-font-family: Arial; mso-char-type: symbol; mso-hansi-font-family: Arial; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;"></span></span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">-----------------------></span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: Wingdings; font-size: 9.0pt; line-height: 115%; mso-ascii-font-family: Arial; mso-bidi-font-family: Arial; mso-char-type: symbol; mso-hansi-font-family: Arial; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;"></span></span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"> --------------</span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: Wingdings; font-size: 9.0pt; line-height: 115%; mso-ascii-font-family: Arial; mso-bidi-font-family: Arial; mso-char-type: symbol; mso-hansi-font-family: Arial; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">></span></span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">-----------------------></span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: Wingdings; font-size: 9.0pt; line-height: 115%; mso-ascii-font-family: Arial; mso-bidi-font-family: Arial; mso-char-type: symbol; mso-hansi-font-family: Arial; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;"></span></span></b></div>
</td>
</tr>
<tr style="height: 16.3pt; mso-yfti-irow: 1;">
<td style="border-top: none; border: solid windowtext 1.0pt; height: 16.3pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 139.05pt;" valign="top" width="185"><div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif";">Client A</span></b></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 16.3pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 184.25pt;" valign="top" width="246"><div class="MsoNormal" style="margin-left: -1.9pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Server</span></b></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 16.3pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 131.95pt;" valign="top" width="176"><div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Client
B</span></b></div>
</td>
</tr>
<tr style="height: 170.9pt; mso-yfti-irow: 2;">
<td style="border-top: none; border: solid windowtext 1.0pt; height: 170.9pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 139.05pt;" valign="top" width="185"><div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">2. Client-A create IP End Point and a socket object.</span></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">4. Client A Prepare byte
data from file which will be sent to server.</span></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">5. Client A tries to
connect server using client socket by help of IP end point.</span></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">8. Connection established with client A and server.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">11. Client A starts
sending byte data over connected socket.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">20. Client A receive file transfer success message from
server.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">22. Socket object closes and dispose.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">24. Client A process ends here.</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 170.9pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 184.25pt;" valign="top" width="246"><div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">1. Server creates an IP End Point and a socket object
then bind socket object with IP end point and sends it to listen mode for
incoming client request.</span><span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;"></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">7. Server
receives two client requests and accept these. Once connection established,
server create new socket object for each connection (here total two, suppose
sockObjectA for Client A and sockObjectB for Client B). These will handle client’s
all requests until connection ends. Client will be informed internally by TCP
about connect success. In our case sockObjectA will receive data and sockObjectB
will send data. </span></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">For real
life application can use socket object list (say array list or hash table)
with some hash table to track client name and socket object name.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">10. Start preparations
to store incoming byte data from client A through sockObjectA.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">12. Server receives file byte data along with file name
and stores it in byte array. For large file can store in temporary file but I
would suggest to store in array for faster processing. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">13. Server starts sending byte data over connected
socket sockObjectB to client B.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">19. Server receive EOF successful message from client B
and pass information to client A about file transfer success.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">21. Server initiate to disconnect socket connection for
sockObjectA and sockObjectB, so connection break with server and client A and
B.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">26. Server process ends here for my case. For real life
project server will stay in listen mode for next client request.</span></div>
<div class="MsoNormal">
<br /></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 170.9pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 131.95pt;" valign="top" width="176"><div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">3. Client B creates IP End Point and a socket object.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">6. Client B tries to connect server using client socket
by help of IP end point.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">9. Connection established with client A and server.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">14. Client B receives file byte data along with file
name and stores it in byte array.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">15. Client retrieve file name from received byte data.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">16. Client opens a binary stream writer with file name
to store byte data in it. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">17. Once file save complete client (do some technique
to understand End Of File - EOF) closes binary stream writer and server
socket objects.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">18. Send a message to server to inform client A about
file transfer success.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">23. Socket object closes and dispose.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">25. Client B process here.</span></div>
</td>
</tr>
<tr style="height: 31.45pt; mso-yfti-irow: 3; mso-yfti-lastrow: yes;">
<td colspan="3" style="border-top: none; border: solid windowtext 1.0pt; height: 31.45pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 455.25pt;" valign="top" width="607"><div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">If you send large file then logic will be same and you
need to loop step 11 to 20 until file ends. Here I have used EOF and then can
use some fixed data packet every time. So once each packet receive in Client
B, it will inform that successful receive of packet number and ask server to
send next packet. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">For large file server will store file temporarily
because connection speed in client A and B may not be same. Client A can send
much faster data but client B may get it very slow. So buffering concept need
to implement in server.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">If possible I shall write this code in future.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Now I am posting this logic next will write code and
once finish will post it for you with downloadable source code.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
</td>
</tr>
</tbody></table>
</span></div>
<br />
<div class="MsoNormal" style="margin-left: 18.0pt;">
<br /></div>
<br />
<br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]--></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-67542955519089046312013-02-15T06:37:00.002+05:302014-03-25T09:39:11.617+05:30Country list in TSQL -MS SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
This article just for easy reference of country list in TSQL format so you can just copy paste and get full country list in minutes:<br />
<br />
If you like to save your long time please just spend 5 seconds for me by clicking on an advertisement. :D<br />
<br />
<br />
<b>Table Structure SQL</b><br />
<br />
CREATE TABLE [dbo].[Country](<br />
[SlNo] [int] IDENTITY(1,1) NOT NULL,<br />
[CountryName] [nvarchar](100) NOT NULL,<br />
[CountryCode] [nvarchar](10) NULL<br />
)<br />
<br />
<b>Insert SQL</b><br />
<br />
<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AF','Afghanistan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AL','Albania');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('DZ','Algeria');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AS','American Samoa');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AD','Andorra');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AO','Angola');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AI','Anguilla');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AQ','Antarctica');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AG','Antigua and Barbuda');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AR','Argentina');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AM','Armenia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AW','Aruba');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AU','Australia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AT','Austria');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AZ','Azerbaijan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BS','Bahamas');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BH','Bahrain');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BD','Bangladesh');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BB','Barbados');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BY','Belarus');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BE','Belgium');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BZ','Belize');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BJ','Benin');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BM','Bermuda');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BT','Bhutan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BO','Bolivia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BA','Bosnia and Herzegovina');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BW','Botswana');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BV','Bouvet Island');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BR','Brazil');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('IO','British Indian Ocean Territory');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('VG','British Virgin Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BN','Brunei');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BG','Bulgaria');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BF','Burkina Faso');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('BI','Burundi');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KH','Cambodia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CM','Cameroon');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CA','Canada');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CV','Cape Verde');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KY','Cayman Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CF','Central African Republic');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TD','Chad');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CL','Chile');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CN','China');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CX','Christmas Island');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CC','Cocos (Keeling) Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CO','Colombia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KM','Comoros');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CG','Congo');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CD','Congo - Democratic Republic of');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CK','Cook Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CR','Costa Rica');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CI','Cote d''Ivoire');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('HR','Croatia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CU','Cuba');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CY','Cyprus');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CZ','Czech Republic');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('DK','Denmark');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('DJ','Djibouti');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('DM','Dominica');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('DO','Dominican Republic');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TP','East Timor');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('EC','Ecuador');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('EG','Egypt');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SV','El Salvador');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GQ','Equitorial Guinea');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('ER','Eritrea');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('EE','Estonia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('ET','Ethiopia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('FK','Falkland Islands (Islas Malvinas)');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('FO','Faroe Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('FJ','Fiji');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('FI','Finland');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('FR','France');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GF','French Guyana');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PF','French Polynesia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TF','French Southern and Antarctic Lands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GA','Gabon');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GM','Gambia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GZ','Gaza Strip');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GE','Georgia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('DE','Germany');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GH','Ghana');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GI','Gibraltar');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GR','Greece');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GL','Greenland');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GD','Grenada');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GP','Guadeloupe');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GU','Guam');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GT','Guatemala');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GG','Guernsey');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GN','Guinea');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GW','Guinea-Bissau');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GY','Guyana');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('HT','Haiti');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('HM','Heard Island and McDonald Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('VA','Holy See (Vatican City)');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('HN','Honduras');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('HK','Hong Kong');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('HU','Hungary');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('IS','Iceland');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('IN','India');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('ID','Indonesia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('IR','Iran');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('IQ','Iraq');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('IE','Ireland');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('IM','Isle of Man');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('IL','Israel');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('IT','Italy');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('JM','Jamaica');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('JP','Japan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('JE','Jersey');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('JO','Jordan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KZ','Kazakhstan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KE','Kenya');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KI','Kiribati');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KW','Kuwait');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KG','Kyrgyzstan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LA','Laos');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LV','Latvia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LB','Lebanon');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LS','Lesotho');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LR','Liberia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LY','Libya');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LI','Liechtenstein');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LT','Lithuania');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LU','Luxembourg');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MO','Macau');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MK','Macedonia - The Former Yugoslav Republic of');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MG','Madagascar');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MW','Malawi');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MY','Malaysia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MV','Maldives');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('ML','Mali');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MT','Malta');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MH','Marshall Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MQ','Martinique');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MR','Mauritania');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MU','Mauritius');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('YT','Mayotte');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MX','Mexico');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('FM','Micronesia - Federated States of');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MD','Moldova');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MC','Monaco');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MN','Mongolia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MS','Montserrat');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MA','Morocco');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MZ','Mozambique');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MM','Myanmar');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NA','Namibia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NR','Nauru');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NP','Nepal');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NL','Netherlands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AN','Netherlands Antilles');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NC','New Caledonia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NZ','New Zealand');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NI','Nicaragua');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NE','Niger');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NG','Nigeria');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NU','Niue');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NF','Norfolk Island');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('MP','Northern Mariana Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KP','North Korea');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('NO','Norway');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('OM','Oman');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PK','Pakistan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PW','Palau');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PA','Panama');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PG','Papua New Guinea');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PY','Paraguay');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PE','Peru');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PH','Philippines');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PN','Pitcairn Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PL','Poland');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PT','Portugal');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PR','Puerto Rico');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('QA','Qatar');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('RE','Reunion');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('RO','Romania');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('RU','Russia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('RW','Rwanda');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KN','Saint Kitts and Nevis');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LC','Saint Lucia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('VC','Saint Vincent and the Grenadines');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('WS','Samoa');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SM','San Marino');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('ST','Sao Tome and Principe');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SA','Saudi Arabia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SN','Senegal');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CS','Serbia and Montenegro');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SC','Seychelles');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SL','Sierra Leone');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SG','Singapore');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SK','Slovakia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SI','Slovenia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SB','Solomon Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SO','Somalia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('ZA','South Africa');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GS','South Georgia and the South Sandwich Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('KR','South Korea');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('ES','Spain');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('LK','Sri Lanka');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SH','St. Helena');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PM','St. Pierre and Miquelon');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SD','Sudan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SR','Suriname');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SJ','Svalbard');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SZ','Swaziland');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SE','Sweden');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('CH','Switzerland');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('SY','Syria');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TW','Taiwan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TJ','Tajikistan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TZ','Tanzania');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TH','Thailand');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TL','Timor-Leste');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TG','Togo');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TK','Tokelau');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TO','Tonga');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TT','Trinidad and Tobago');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TN','Tunisia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TR','Turkey');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TM','Turkmenistan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TC','Turks and Caicos Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('TV','Tuvalu');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('UG','Uganda');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('UA','Ukraine');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('AE','United Arab Emirates');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('GB','United Kingdom');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('US','United States');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('UM','United States Minor Outlying Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('VI','United States Virgin Islands');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('UY','Uruguay');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('UZ','Uzbekistan');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('VU','Vanuatu');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('VE','Venezuela');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('VN','Vietnam');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('WF','Wallis and Futuna');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('PS','West Bank');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('EH','Western Sahara');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('YE','Yemen');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('ZM','Zambia');<br />
INSERT INTO [Country] ([CountryCode], [CountryName]) VALUES('ZW','Zimbabwe');</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com1tag:blogger.com,1999:blog-4193683792173214666.post-91814096829684289752012-10-20T06:00:00.000+05:302014-03-19T23:24:28.998+05:30Send File from Server to Client using C# Socket Programming <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<span style="font-family: Arial; font-size: small;">Hello Friends, after long day’s
gap I am writing some blog for you. During this time many things has changed in
technological world like earlier I write code with VS 2008 and now VS 2012 has
released. Also lots of changes in our life too. I believe this time I can write
my blog with better English than earlier, which will help you to read this. Ok
lets read this post about to learn new thing which is about to send small file
from server to client. This is just opposite of sending file from client to
server. This is the basic of large file transfer, later I shall use the same
thing to send large file from server to client and finally will use both
(client to server and server to client) large file transfer code client to
client. I shall come to that point step by step.</span><br />
<span style="font-size: small;"><br /></span>
<span style="font-family: Arial; font-size: small;">To send file from server to client need to follow below steps as describe in table by client and server:</span><br />
<br />
<span style="font-family: Arial;"><!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--></span><br />
<span style="font-family: Arial;"><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
</span><b style="mso-bidi-font-weight: normal;"><span style="font-family: Arial;"></span>File Transfer from Server to Client</b><span style="font-family: Arial;">
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; margin-left: 5.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt;">
<tbody>
<tr style="height: 17.5pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; height: 17.5pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 214.75pt;" valign="top" width="286"><div class="MsoNormal" style="margin-left: -1.9pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Server</span></b></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; height: 17.5pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 224.7pt;" valign="top" width="300"><div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Client</span></b></div>
</td>
</tr>
<tr style="height: 148.4pt; mso-yfti-irow: 1; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; height: 148.4pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 214.75pt;" valign="top" width="286"><div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">1. Server creates an IP End Point and a socket object
then bind socket object with IP end point and sends it to listen mode for
incoming client request.</span><span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;"></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">4. Server
receive client request and accept it. Once connection established, server
create another socket object which will handle this client all requests until
connection ends. Client will be informed internally by TCP about connect success.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">6.</span><span lang="EN" style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">
</span><span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Prepare
byte data from file which will be sent to client.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">7. Server starts sending
byte data over connected socket.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: -1.9pt;">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">12. Once data transfer
complete and client closes socket connection, server also close server socket
object.</span></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">13. Server program work ends here.</span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; height: 148.4pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 224.7pt;" valign="top" width="300"><div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">2. Client creates an IP End Point and a socket object.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">3. Try to connect to server using client socket by help
of IP end point.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span lang="EN" style="color: black; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-ansi-language: EN;">5. Start preparations
to store incoming byte data from server.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">8. Client receives file byte data along with file name
and stores it in byte array.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">9. Client retrieve file name from byte data.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">10. Client opens a binary stream writer with file name
to store byte data in it. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">11. Once file save complete client closes binary stream
writer and server socket objects.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">14. Client program work ends here.</span></div>
</td>
</tr>
</tbody></table>
</span><br />
<span style="font-family: Arial;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">To send file from server to
client there must be two applications that is Server application and client
application. In code I have mentioned these two parts individually. In below
section I am describing Server action means server application is working and
you need to check server code, for client action need to check client code.
Handshaking of these two socket programming applications should be following:<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<!-- Google adds --><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">
</span></span><!-- Googl adds ends -->
<br />
<div class="MsoNormal">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><b>1) Server Action: </b>First need to run server application, this server application will open
an endpoint with predefined IP address and port number and will remain in
listen mode to accept new socket connection request from client. <o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">It’s just like some one is
waiting at some fixed position to reply on some ones request. <o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div class="MsoNormal">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">This below section of code
from server application is doing exactly same thing:<o:p></o:p></span></span></div>
<div class="MsoNormal">
<br /></div>
<blockquote class="tr_bq">
<div class="MsoNormal">
<span style="color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">IPEndPoint</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> ipEnd = <span style="color: blue;">new</span> <span style="color: #2b91af;">IPEndPoint</span>(<span style="color: #2b91af;">IPAddress</span>.Any,
5656);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">Socket</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> sock = <span style="color: blue;">new</span> <span style="color: #2b91af;">Socket</span>(<span style="color: #2b91af;">AddressFamily</span>.InterNetwork,
<span style="color: #2b91af;">SocketType</span>.Stream, <span style="color: #2b91af;">ProtocolType</span>.IP);<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">sock.Bind(ipEnd);</span></div>
<div class="MsoNormal">
<span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">sock.Listen(100);<o:p></o:p></span></div>
</blockquote>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: Arial; font-size: small;">Here line no 1 is creating
an ipEnd point with port number 5656 and IP is local machine IP address. Port
number can be anything except well known port number (port number should be
more than 1024).<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: Arial; font-size: small;">Next two lines are creating
a socket object and binding with previously created IPEnd point.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: Arial; font-size: small;">Last line is sending newly
created socket object to listen mode to accept new connection request from
client.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: Arial; font-size: small;">So you need to run server
application first and then client application.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><br /></span></div>
<!-- Google adds --><span style="font-size: small;">
</span><!-- Googl adds ends -->
<br />
<div>
<div>
<div style="margin: 0cm;">
<span style="font-size: small;"><b><span style="font-family: Arial, sans-serif;">2) Client Action</span></b><span style="font-family: Arial, sans-serif;">: Now
turn is coming to client to request server.</span></span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<blockquote class="tr_bq">
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">IPAddress</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
ipAddress =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">Dns</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.GetHostAddresses(</span><span style="color: #a31515; font-family: ""Courier New"","serif"; font-size: 10.0pt;">"localhost"</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">);</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">IPEndPoint</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">ipEnd =<span class="apple-converted-space"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">new</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">IPEndPoint</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">(ipAddress[0], 5656);</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">Socket</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">clientSock =<span class="apple-converted-space"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">new</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">Socket</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">(</span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">AddressFamily</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.InterNetwork,<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">SocketType</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.Stream,<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">ProtocolType</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.IP);</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">clientSock.Connect(ipEnd);</span></div>
</blockquote>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: small;">These codes are from client
application, here first two lines are using to get Localhost IP address and by
using this creating new IPEnd point. Be sure there IP address and port number
must be same as server address. I am running my applications in same machine so
using localhost.</span></div>
<br />
<div style="margin: 0cm;">
<span style="font-size: small;"><br /></span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: small;">Next two lines of code is
creating a socket object and trying to connect by using IPEnd point. So this
socket object will try to connect server socket which was in listen mode.</span></div>
<br />
<div style="margin: 0cm;">
<span style="font-size: small;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-size: small;"><b><span style="font-family: Arial, sans-serif;">3) Server Action</span></b><span style="font-family: Arial, sans-serif;">: Again
turn comes to server about to response on client’s request and this is doing by
below line of code in server application:</span></span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<blockquote class="tr_bq">
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">Socket</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">clientSock = sock.Accept();</span></div>
</blockquote>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: small;">This “sock” is server socket
object which was created previously and it was in listen mode. This sock object
will accept client request and generate a new socket object with name
“clientSock”. Rest all work in server side will be performed by “clientSock”
object to handle this particular client request.</span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: small;"><br /></span></div>
<br />
<span style="font-size: small;"><b><span style="font-family: Arial, sans-serif;">4) Server Action</span></b><span style="font-family: Arial, sans-serif;">: These
codes are not directly related with socket programming. This is using to read
and send file to client.</span></span><br />
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<blockquote class="tr_bq">
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">string</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileName =<span class="apple-converted-space"> </span></span><span style="color: #a31515; font-family: ""Courier New"","serif"; font-size: 10.0pt;">"test.txt"</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">;</span><span style="color: green; font-family: ""Courier New"","serif"; font-size: 10.0pt;">//
"Your File Name";</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">string</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">filePath =<span class="apple-converted-space"> </span></span><span style="color: #a31515; font-family: ""Courier New"","serif"; font-size: 10.0pt;">@"C:\FT\"</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">;</span><span style="color: green; font-family: ""Courier New"","serif"; font-size: 10.0pt;">//Your
File Path;</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
fileNameByte =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">Encoding</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.ASCII.GetBytes(fileName);</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
fileData =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">File</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.ReadAllBytes(filePath
+ fileName);</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
clientData =<span class="apple-converted-space"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">new</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[4 + fileNameByte.Length +
fileData.Length];</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
fileNameLen =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">BitConverter</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.GetBytes(fileNameByte.Length);</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileNameLen.CopyTo(clientData,
0);</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileNameByte.CopyTo(clientData,
4);</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileData.CopyTo(clientData, 4
+ fileNameByte.Length);</span></div>
</blockquote>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: small;">These lines of code reading some
particular file from local drive and string its data in byte array
“clientData”. File data need to store in array with raw byte format to send
these to client. With data file name size string at initial of file data. This
is predefined between client and server and it needs to do, otherwise client
will not get file name which is sending by server.</span></div>
<br />
<div style="margin: 0cm;">
<span style="font-size: small;"><br /></span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: small;">For my case I am using first four
byte to represent file name length and form 5<sup>th</sup><span class="apple-converted-space"> </span>byte file name is storing. So all file
data will store after file name.</span></div>
<br />
<div style="margin: 0cm;">
<span style="font-size: small;"><br /></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><b><span style="font-family: Arial, sans-serif;">5) Server Action:</span></b><span class="apple-converted-space"><span style="font-family: Arial, sans-serif;"> </span></span><span style="font-family: Arial, sans-serif;">Now file data is in byte array and it needs
to send to client. The same thing is happening by using below code with the
help of client socket (clientSock) object, which was created during client
request acceptance.</span></span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<blockquote class="tr_bq">
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">clientSock.Send(clientData);</span></div>
</blockquote>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">Basically server application task
ends here for small file transfer. Remaining code has used for some decoration
and socket closing related things.</span></span></div>
<br />
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><b>5) Client Action:</b><span class="apple-converted-space"> </span>Now again turn comes to client and it will
perform below tasks:</span></span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<blockquote class="tr_bq">
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
clientData =<span class="apple-converted-space"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">new</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[1024 * 5000];</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">string</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">receivedPath =<span class="apple-converted-space"> </span></span><span style="color: #a31515; font-family: ""Courier New"","serif"; font-size: 10.0pt;">"C:/"</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">;</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">int</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">receivedBytesLen =
clientSock.Receive(clientData);</span></div>
</blockquote>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: small;">Here first two lines are just
creating byte array to store server data and path is used to decide where data
to be save. In my code, I am saving data in C: drive.</span></div>
<br />
<div style="margin: 0cm;">
<span style="font-size: small;"><br /></span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: small;">Last line is start receiving data
from server. Whenever client socket starts receiving server data then it
returns length of data which has captured in a integer variable.</span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: small;"><br /></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><b><span style="font-family: Arial, sans-serif;">6) Client Action</span></b><span style="font-family: Arial, sans-serif;">: This
section of code is retrieving file name length and by using this file name
which was sent by server at the starting of file data. This will require
retrieving file name.</span></span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<blockquote class="tr_bq">
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">int</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileNameLen =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">BitConverter</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.ToInt32(clientData,
0);</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">string</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileName =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">Encoding</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.ASCII.GetString(clientData,
4, fileNameLen);</span></div>
</blockquote>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><b><span style="font-family: Arial, sans-serif;">7) Client Action:</span></b><span class="apple-converted-space"><span style="font-family: Arial, sans-serif;"> </span></span><span style="font-family: Arial, sans-serif;">Now received data is saving at client side by
using below lines of code with the help of binary stream writer.</span></span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<blockquote class="tr_bq">
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">BinaryWriter</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">bWrite =<span class="apple-converted-space"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">new</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">BinaryWriter</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">(</span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">File</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.Open(receivedPath
+ fileName,<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">FileMode</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.Append));</span></div>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">bWrite.Write(clientData, 4 +
fileNameLen, receivedBytesLen - 4 - fileNameLen);</span></div>
</blockquote>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">Here file data is starting to
retrieve after file size and file name bytes. This has managed in 2<sup>nd</sup><span class="apple-converted-space"> </span>line.</span></span></div>
<br />
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">By that way one small file can be
sent from server to client.</span></span></div>
<br />
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><b>8) Client and Server
Action</b>: Now server and client both will do same activity; that is to
release server and client socket by using close method of socket. Client needs
to close binary stream writer as well.</span></span></div>
<br />
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">So by following these steps a
file can be sent from server to client. Same way we can send large file from
server to client. TCP buffer can not handle large data size at a time. So if
you try to send large file it will throw overflow error. To avoid this error
you need to slice big file in small pieces (same thing has applied in 2GB file
transfer article) and need to send one by one slice. So there will be loop to
send file from server to client that means step 5 to step 7 will repeat.</span></span></div>
<br />
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">Also server can send some
particular file based on client request. But for that client need to send file
name at the time of server request. So server can search file based on this
information, so can read and send particular file to client.</span></span></div>
<br />
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">By handling multiple clients
objects one server can send file to multiple clients simultaneously but for
that you need to create multithread application and need to keep track client
socket object array with data file. So programming must be more complex. I am
planning to write codes up to multiple client to client large file transfer
with the help of one server application step by step. So keep watching my blog
to learn new things.</span></span></div>
<br />
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">Download this project from below
link:</span></span></div>
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span><div style="margin: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">Full codes are here...</span></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><u><span style="color: #3333ff; font-size: 13.5pt;">Client code:</span></u></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<blockquote class="tr_bq">
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.Collections.Generic;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.Text;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.Net;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.Net.Sockets;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.IO;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">namespace Client_Socket</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">//FILE TRANSFER USING C#.NET SOCKET - CLIENT</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">class Program</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">static void Main(string[] args)</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">try</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Console.WriteLine("That program can transfer small file. I've
test up to 850kb file");</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">IPAddress[] ipAddress =
Dns.GetHostAddresses("localhost");</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">IPEndPoint ipEnd = new IPEndPoint(ipAddress[0], 5656);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Socket clientSock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.IP);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">clientSock.Connect(ipEnd);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">byte[] clientData = new byte[1024 * 5000];</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">string receivedPath = "C:/";</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">int receivedBytesLen = clientSock.Receive(clientData);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">int fileNameLen = BitConverter.ToInt32(clientData, 0);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">string fileName = Encoding.ASCII.GetString(clientData, 4,
fileNameLen);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Console.WriteLine("Client:{0} connected & File {1}
started received.", clientSock.RemoteEndPoint, fileName);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">BinaryWriter bWrite = new BinaryWriter(File.Open(receivedPath +
fileName, FileMode.Append)); ;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">bWrite.Write(clientData, 4 + fileNameLen, receivedBytesLen - 4 -
fileNameLen);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Console.WriteLine("File: {0} received & saved at
path: {1}", fileName, receivedPath);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">bWrite.Close();</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">clientSock.Close();</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Console.ReadLine();</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">catch (Exception ex)</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Console.WriteLine("File Sending fail." + ex.Message);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
</blockquote>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;"><br /></span></div>
<br /><div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Server codes are here...</span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></b></div>
<br />
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><u><span style="color: #3333ff; font-size: 18.0pt;">Server code:</span></u></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<blockquote class="tr_bq">
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.Collections.Generic;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.Text;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.Net;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.Net.Sockets;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">using System.IO;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">namespace beginSocketServer</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">//FILE TRANSFER USING C#.NET SOCKET - SERVER</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">class Program</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">static void Main(string[] args)</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">try</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Console.WriteLine("That program can transfer small file. I've
test up to 850kb file");</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">IPEndPoint ipEnd = new IPEndPoint(IPAddress.Any, 5656);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.IP);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">sock.Bind(ipEnd);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">sock.Listen(100);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">//clientSock is the socket object of client, so we can use it now
to transfer data to client</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Socket clientSock = sock.Accept();</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">string fileName = "test.txt";// "Your File
Name";</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">string filePath = @"C:\FT\";//Your File Path;</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">byte[] fileNameByte = Encoding.ASCII.GetBytes(fileName);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">byte[] fileData = File.ReadAllBytes(filePath + fileName);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">byte[] clientData = new byte[4 + fileNameByte.Length +
fileData.Length];</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">byte[] fileNameLen = BitConverter.GetBytes(fileNameByte.Length);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">fileNameLen.CopyTo(clientData, 0);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">fileNameByte.CopyTo(clientData, 4);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">fileData.CopyTo(clientData, 4 + fileNameByte.Length);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">clientSock.Send(clientData);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Console.WriteLine("File:{0} has been sent.", fileName);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"><br /></span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">clientSock.Close();</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Console.ReadLine();</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">catch (Exception ex)</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">{</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Console.WriteLine("File Receiving fail." + ex.Message);</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
<div style="margin: 0cm;">
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">}</span></span></div>
</blockquote>
<br /></div>
</div>
</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com105tag:blogger.com,1999:blog-4193683792173214666.post-8217722027728094932012-10-20T05:15:00.003+05:302014-03-25T09:39:11.620+05:30Send File from Server to Client using C# Socket Programming 6/6<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Wingdings; font-size: 13.5pt;"><a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c_6960.html">ß </a></span></b><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c_6960.html">Previous part</a><o:p></o:p></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Server codes are here...</span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></b></div>
<br />
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><u><span style="color: #3333ff; font-size: 18.0pt;">Server code:</span></u></b><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.Collections.Generic;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.Text;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.Net;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.Net.Sockets;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.IO;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">namespace beginSocketServer<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">//FILE TRANSFER USING C#.NET SOCKET - SERVER<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">class Program<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">static void Main(string[] args)<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">try<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Console.WriteLine("That program can transfer small file. I've
test up to 850kb file");<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">IPEndPoint ipEnd = new IPEndPoint(IPAddress.Any, 5656);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.IP);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">sock.Bind(ipEnd);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">sock.Listen(100);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">//clientSock is the socket object of client, so we can use it now
to transfer data to client<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Socket clientSock = sock.Accept();<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">string fileName = "test.txt";// "Your File
Name";<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">string filePath = @"C:\FT\";//Your File Path;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">byte[] fileNameByte = Encoding.ASCII.GetBytes(fileName);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">byte[] fileData = File.ReadAllBytes(filePath + fileName);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">byte[] clientData = new byte[4 + fileNameByte.Length +
fileData.Length];<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">byte[] fileNameLen = BitConverter.GetBytes(fileNameByte.Length);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">fileNameLen.CopyTo(clientData, 0);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">fileNameByte.CopyTo(clientData, 4);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">fileData.CopyTo(clientData, 4 + fileNameByte.Length);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">clientSock.Send(clientData);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Console.WriteLine("File:{0} has been sent.", fileName);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">clientSock.Close();<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Console.ReadLine();<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">catch (Exception ex)<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Console.WriteLine("File Receiving fail." + ex.Message);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
</div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-12421482030806566882012-10-20T05:14:00.001+05:302014-03-25T09:39:11.593+05:30Send File from Server to Client using C# Socket Programming 5/6<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Wingdings; font-size: 13.5pt;"><a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c_1442.html">ß </a></span></b><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c_1442.html">Previous part</a><o:p></o:p></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Full codes are here...</span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
</div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><u><span style="color: #3333ff; font-size: 13.5pt;">Client code:</span></u></b><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.Collections.Generic;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.Text;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.Net;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.Net.Sockets;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">using System.IO;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">namespace Client_Socket<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">//FILE TRANSFER USING C#.NET SOCKET - CLIENT<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">class Program<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">static void Main(string[] args)<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">try<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Console.WriteLine("That program can transfer small file. I've
test up to 850kb file");<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">IPAddress[] ipAddress =
Dns.GetHostAddresses("localhost");<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">IPEndPoint ipEnd = new IPEndPoint(ipAddress[0], 5656);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Socket clientSock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.IP);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">clientSock.Connect(ipEnd);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">byte[] clientData = new byte[1024 * 5000];<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">string receivedPath = "C:/";<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">int receivedBytesLen = clientSock.Receive(clientData);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">int fileNameLen = BitConverter.ToInt32(clientData, 0);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">string fileName = Encoding.ASCII.GetString(clientData, 4,
fileNameLen);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Console.WriteLine("Client:{0} connected & File {1}
started received.", clientSock.RemoteEndPoint, fileName);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">BinaryWriter bWrite = new BinaryWriter(File.Open(receivedPath +
fileName, FileMode.Append)); ;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">bWrite.Write(clientData, 4 + fileNameLen, receivedBytesLen - 4 -
fileNameLen);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Console.WriteLine("File: {0} received & saved at
path: {1}", fileName, receivedPath);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">bWrite.Close();<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">clientSock.Close();<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Console.ReadLine();<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">catch (Exception ex)<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">{<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">Console.WriteLine("File Sending fail." + ex.Message);<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-size: 13.5pt;"><br /></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
</div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c_6565.html"><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Next part (Server Code) </span></b><b><span style="font-family: Wingdings; font-size: 13.5pt;">à</span></b></a><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><o:p></o:p></span></b></div>
<br />
<br /></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0tag:blogger.com,1999:blog-4193683792173214666.post-19656800314042836972012-10-20T05:12:00.001+05:302014-03-25T09:39:11.600+05:30Send File from Server to Client using C# Socket Programming 4/6<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Wingdings; font-size: 13.5pt;"><a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c_20.html">ß </a></span></b><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c_20.html">Previous part</a><o:p></o:p></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
</div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">6) Client Action</span></b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">: This
section of code is retrieving file name length and by using this file name
which was sent by server at the starting of file data. This will require
retrieving file name.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">int</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileNameLen =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">BitConverter</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.ToInt32(clientData,
0);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">string</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileName =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">Encoding</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.ASCII.GetString(clientData,
4, fileNameLen);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">7) Client Action:</span></b><span class="apple-converted-space"><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"> </span></span><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Now received data is saving at client side by
using below lines of code with the help of binary stream writer.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">BinaryWriter</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">bWrite =<span class="apple-converted-space"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">new</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">BinaryWriter</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">(</span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">File</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.Open(receivedPath
+ fileName,<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">FileMode</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.Append));</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">bWrite.Write(clientData, 4 +
fileNameLen, receivedBytesLen - 4 - fileNameLen);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Here file data is starting to
retrieve after file size and file name bytes. This has managed in 2<sup>nd</sup><span class="apple-converted-space"> </span>line.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">By that way one small file can be
sent from server to client.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">8) Client and Server
Action</span></b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">: Now server and client both will do same activity; that is to
release server and client socket by using close method of socket. Client needs
to close binary stream writer as well.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">So by following these steps a
file can be sent from server to client. Same way we can send large file from
server to client. TCP buffer can not handle large data size at a time. So if
you try to send large file it will throw overflow error. To avoid this error
you need to slice big file in small pieces (same thing has applied in 2GB file
transfer article) and need to send one by one slice. So there will be loop to
send file from server to client that means step 5 to step 7 will repeat.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Also server can send some
particular file based on client request. But for that client need to send file
name at the time of server request. So server can search file based on this
information, so can read and send particular file to client.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">By handling multiple clients
objects one server can send file to multiple clients simultaneously but for
that you need to create multithread application and need to keep track client
socket object array with data file. So programming must be more complex. I am
planning to write codes up to multiple client to client large file transfer
with the help of one server application step by step. So keep watching my blog
to learn new things.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Download this project from below
link:</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: "Arial","sans-serif"; font-size: 13.5pt;">https://rapidshare.com/files/691859425/Client
and Server - Send Small File from Server to Client.zip </span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: "Arial","sans-serif"; font-size: 13.5pt;"><br /></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
</div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c_6960.html"><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Next part ( full codes) </span></b><b><span style="font-family: Wingdings; font-size: 13.5pt;">à</span></b></a><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><o:p></o:p></span></b></div>
<br />
<u1:p></u1:p><br /></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com1tag:blogger.com,1999:blog-4193683792173214666.post-13478231528505283452012-10-20T05:09:00.003+05:302014-03-25T09:39:11.597+05:30Send File from Server to Client using C# Socket Programming 3/6<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Wingdings; font-size: 13.5pt;"><a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c.html">ß </a></span></b><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c.html">Previous part</a><o:p></o:p></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></b></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
</div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">4) Server Action</span></b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">: These
codes are not directly related with socket programming. This is using to read
and send file to client.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">string</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileName =<span class="apple-converted-space"> </span></span><span style="color: #a31515; font-family: ""Courier New"","serif"; font-size: 10.0pt;">"test.txt"</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">;</span><span style="color: green; font-family: ""Courier New"","serif"; font-size: 10.0pt;">//
"Your File Name";</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">string</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">filePath =<span class="apple-converted-space"> </span></span><span style="color: #a31515; font-family: ""Courier New"","serif"; font-size: 10.0pt;">@"C:\FT\"</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">;</span><span style="color: green; font-family: ""Courier New"","serif"; font-size: 10.0pt;">//Your
File Path;</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
fileNameByte =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">Encoding</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.ASCII.GetBytes(fileName);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
fileData =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">File</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.ReadAllBytes(filePath
+ fileName);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
clientData =<span class="apple-converted-space"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">new</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[4 + fileNameByte.Length +
fileData.Length];</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
fileNameLen =<span class="apple-converted-space"> </span></span><span style="color: #2b91af; font-family: ""Courier New"","serif"; font-size: 10.0pt;">BitConverter</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">.GetBytes(fileNameByte.Length);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileNameLen.CopyTo(clientData,
0);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileNameByte.CopyTo(clientData,
4);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">fileData.CopyTo(clientData, 4
+ fileNameByte.Length);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">These lines of code reading some
particular file from local drive and string its data in byte array
“clientData”. File data need to store in array with raw byte format to send
these to client. With data file name size string at initial of file data. This
is predefined between client and server and it needs to do, otherwise client
will not get file name which is sending by server.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">For my case I am using first four
byte to represent file name length and form 5<sup>th</sup><span class="apple-converted-space"> </span>byte file name is storing. So all file
data will store after file name.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">5) Server Action:</span></b><span class="apple-converted-space"><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"> </span></span><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Now file data is in byte array and it needs
to send to client. The same thing is happening by using below code with the
help of client socket (clientSock) object, which was created during client
request acceptance.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">clientSock.Send(clientData);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Basically server application task
ends here for small file transfer. Remaining code has used for some decoration
and socket closing related things.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">5) Client Action:</span></b><span class="apple-converted-space"><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"> </span></span><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Now again turn comes to client and it will
perform below tasks:</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[]
clientData =<span class="apple-converted-space"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">new</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">byte</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">[1024 * 5000];</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">string</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">receivedPath =<span class="apple-converted-space"> </span></span><span style="color: #a31515; font-family: ""Courier New"","serif"; font-size: 10.0pt;">"C:/"</span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">;</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: blue; font-family: ""Courier New"","serif"; font-size: 10.0pt;">int</span><span class="apple-converted-space"><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;"> </span></span><span style="font-family: '', 'Courier New', '', serif; font-size: 10pt;">receivedBytesLen =
clientSock.Receive(clientData);</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Here first two lines are just
creating byte array to store server data and path is used to decide where data
to be save. In my code, I am saving data in C: drive.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<u1:p></u1:p>
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Last line is start receiving data
from server. Whenever client socket starts receiving server data then it
returns length of data which has captured in a integer variable.</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
</div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<a href="http://socketprogramming.blogspot.co.uk/2012/10/send-file-from-server-to-client-using-c_1442.html"><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;">Next part </span></b><b><span style="font-family: Wingdings; font-size: 13.5pt;">à</span></b></a><b><span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><o:p></o:p></span></b></div>
<br />
<u1:p></u1:p><br /></div>
Suman Biswashttp://www.blogger.com/profile/14689783166617654485noreply@blogger.com0