Wednesday, March 18, 2020

Analysis and Summary of essays

Analysis and Summary of essays The First of the trilogy, The Lord of the Rings, the Fellowship of the Ring introduces the reader once again to the world of Middle Earth and all of the magical characters which the writer, J.R.R. Tolkien created. Bilbo Baggins returns, celebrating his 111th birthday, along with Grandalf and the various species of hobbits, elves and other magical creatures. The reader is introduced to Frodo Baggins, Bilbos nephew and heir to Bilbos fortune, and his various friends and counterparts. And again, at the center of the entire fiasco, is the Ring, the symbol of power and control, the one ring to rule all. As in all trilogies, the first edition is marked with the beginning of the story, the introduction of the characters, the building of the plot, and the overall dynamics and underlining of the tale. In this story, the reader is exposed to the moral development of the main character, Frodo Baggins. In much the same way as the human race faces moral corruption and destruction on a dail y basis, the Fellowship of the Ring introduces the Reader to one hobbits personal struggle with overcoming temptation and weakness. The story presented in this book serves the purpose of teacher the reader something about him or herself, or humanity as a whole. By exploring the development of the character of Frodo, as well as dissecting the decisions and difficult situations which Frodo encounters, and finally observing the overall indication of morality on life, it is possible to identify how Tolkien not only entertains through the first of his trilogy, but also enters in important ideas on existance as an entirety. Tolkien created hobbits to be half the size of normal humans. He also created them with half the moral corruption, and twice the heart. A hobbit is a peaceful creature, content with normality and sameness. The typical hobbit never travels far from home, and enjoys repeating most activities every day, through the s...

Sunday, March 1, 2020

How to Exchange Data Over a Network Using Delphi

How to Exchange Data Over a Network Using Delphi Of all the components that  Delphi provides to support applications that exchange data over a network (internet, intranet, and local), two of the most common are  TServerSocket and TClientSocket, both of which are designed to support read and write functions over a TCP/IP connection. Winsock and Delphi Socket Components Windows Sockets (Winsock) provides an open interface for network programming under the Windows operating system. It offers a set of functions, data structures, and related parameters required to access the network services of any protocol stacks. Winsock acts as a link between network applications and underlying protocol stacks. Delphi socket components (wrappers for the Winsock) streamline the creation of applications that communicate with other systems using TCP/IP and related protocols. With sockets, you can read and write over connections to other machines without worrying about the details of the underlying networking software. The internet palette on the Delphi components toolbar hosts the TServerSocket and TClientSocket components as well as TcpClient, TcpServer,  and TUdpSocket. To start a socket connection using a socket component, you must specify a host and a port. In general, host specifies an alias for the IP address of the server system; port specifies the ID number that identifies the server socket connection. A Simple One-Way Program to Send Text To build a simple example using the socket components provided by Delphi, create two forms- one for the server and one for the client computer. The idea is to enable the clients to send some textual data to the server. To start, open Delphi twice, creating one project for the server application and one for the client. Server Side: On a form, insert one TServerSocket component and one TMemo component. In the OnCreate event for the form, add the next code: procedure TForm1.FormCreate(Sender: TObject);begin ServerSocket1.Port : 23; ServerSocket1.Active : True;end; The OnClose event should contain: procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin ServerSocket1.Active : false;end; Client Side: For the client application, add a TClientSocket, TEdit, and TButton component to a form. Insert the following code for the client: procedure TForm1.FormCreate(Sender: TObject);begin ClientSocket1.Port : 23; //local TCP/IP address of the server ClientSocket1.Host : 192.168.167.12; ClientSocket1.Active : true;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin ClientSocket1.Active : false;end;procedure TForm1.Button1Click(Sender: TObject);beginif ClientSocket1.Active then ClientSocket1.Socket.SendText(Edit1.Text);end; The code pretty much describes itself: when a client clicks a button, the text specified inside the Edit1 component will be sent to the server with specified port and host address. Back to the Server: The final touch in this sample is to provide a function for the server to see the data the client is sending. The event we are interested in is OnClientRead- it occurs when the server socket should read information from a client socket. procedure TForm1.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket);begin Memo1.Lines.Add(Socket.ReceiveText);end; When  more than one client sends data to the server, youll need a little more to code: procedure TForm1.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket);var i:integer; sRec : string;beginfor i : 0 to ServerSocket1.Socket.ActiveConnections-1 dobeginwith ServerSocket1.Socket.Connections[i] dobegin sRec : ReceiveText; if sRecr thenbegin Memo1.Lines.Add(RemoteAddress sends :) ; Memo1.Lines.Add(sRecr); end; end; end;end; When the server reads information from a client socket, it adds that text to the Memo component; both the text and the client RemoteAddress are added, so youll know which client sent the information. In more sophisticated implementations, aliases for known IP addresses can serve as a substitute. For a more complex project that uses these components, explore the Delphi Demos Internet Chat project. Its a simple network chat application that uses one form (project) for both the server and the client.