All Entries Tagged With: "data"
Terminate the ability to send or receive data using the Socket.Shutdown method in C#
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
public class SocketShutdownSample
{
public static void Main()
{
IPAddress ip = IPAddress.Parse("127.0.0.1");
string targ = "/default.htm";
Socket skt = new Socket(AddressFamily.InterNetwork,
[...]
How to control the transfer behavior when sending and receiving data on a Socket instance in C#
We can use the System.Net.Sockets SocketFlags Enumeration to control the transfer behavior when sending and receiving data on a Socket instance in C#.
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
public class SocketFlagsSample
{
public static void Main()
{
IPAddress ip = IPAddress.Parse("127.0.0.1");
[...]
Socket class to send data and receive the response
The Socket class creates a managed version of an Internet transport service. Once the Socket is created, the Socket is bound to a specific endpoint through the Socket.Bind method, and the connection to that endpoint is established through the Socket.Connect method. Data is sent to the Socket using the Socket.Send or Socket.SendTo methods, and data [...]
Request and Display Basic Viewer Data in Open Social
Step 1. Request data:
a. Create DataRequest object by calling opensocial.newDataRequest.
b. For each request you wish to make, create it using one of the opensocial.new* methods.
c. For each piece of data you want to request, add a request via DataRequest.add(request).
d. [...]
Read data from SQL server and convert it to XML in C#
Example code to Read data from SQL server and convert it to XML:
using System;
using System.Data;
using System.Xml;
using System.Data.SqlClient;
using System.IO;
public class TestWriteXML
{
public static void Main()
{
String strFileName = c:/temp/out.xml;
SqlConnection conn = new SqlConnection(server=localhost;uid=sa;pwd=;database=db);
[...]
Read file up to 1024 bytes of data in csharp
Stream stream = File.OpenRead(@"C:\data\file.xml");
int bytesToRead = 1024;
int bytesRead = 0;
byte [ ] buffer = new byte [bytesToRead];
// Fill up the buffer repeatedly until we reach the end of file
do {
bytesRead = stream.Read(buffer, 0, bytesToRead);
Console.Write(Encoding.ASCII.GetChars(buffer,0, bytesRead));
} while (bytesToRead == bytesRead);
stream.Close( );
How MVC returns data to browser
The MVC is a design pattern and stands for model-view-controller. When there is no need to fetch data from the database, only the View is called, and loaded by the Controller. Then it is returned to the browser for rendering. When there is the need to fetch some data from the database, the controller calls [...]