<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.sternwarte.uni-erlangen.de/wiki/index.php?action=history&amp;feed=atom&amp;title=Socket</id>
	<title>Socket - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?action=history&amp;feed=atom&amp;title=Socket"/>
	<link rel="alternate" type="text/html" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Socket&amp;action=history"/>
	<updated>2026-04-30T01:07:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.7</generator>
	<entry>
		<id>https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Socket&amp;diff=864&amp;oldid=prev</id>
		<title>Niu at 15:29, 11 April 2018</title>
		<link rel="alternate" type="text/html" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Socket&amp;diff=864&amp;oldid=prev"/>
		<updated>2018-04-11T15:29:57Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:29, 11 April 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l123&quot; &gt;Line 123:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 123:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Isis / Slang]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Niu</name></author>
	</entry>
	<entry>
		<id>https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Socket&amp;diff=860&amp;oldid=prev</id>
		<title>Niu: Created page with &quot;=== tcp_server and tcp_client ===  The main functions of the ''socket''-module are ''socket'', ''bind'', ''listen'', ''accept'', and ''connect''. The [http://www.sternwarte.un...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Socket&amp;diff=860&amp;oldid=prev"/>
		<updated>2018-04-11T15:21:55Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=== tcp_server and tcp_client ===  The main functions of the &amp;#039;&amp;#039;socket&amp;#039;&amp;#039;-module are &amp;#039;&amp;#039;socket&amp;#039;&amp;#039;, &amp;#039;&amp;#039;bind&amp;#039;&amp;#039;, &amp;#039;&amp;#039;listen&amp;#039;&amp;#039;, &amp;#039;&amp;#039;accept&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;connect&amp;#039;&amp;#039;. The [http://www.sternwarte.un...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== tcp_server and tcp_client ===&lt;br /&gt;
&lt;br /&gt;
The main functions of the ''socket''-module are ''socket'', ''bind'', ''listen'', ''accept'', and ''connect''. The [http://www.sternwarte.uni-erlangen.de/isis ISISscripts] functions [http://www.sternwarte.uni-erlangen.de/git.public/index.cgi?p=isisscripts;a=blob;f=src/misc/tcp.sl tcp_server and tcp_client] use these functions to provide a simple server-client-implementation.&lt;br /&gt;
&lt;br /&gt;
===== Example: quick_send and quick_get =====&lt;br /&gt;
As an example usage for these functions, you can find the code of [http://www.sternwarte.uni-erlangen.de/git.public/index.cgi?p=isisscripts;a=blob;f=src/misc/quick_send_get.sl quick_send and quick_get] here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% LAYOUT&lt;br /&gt;
% &lt;br /&gt;
% quick_send      quick_get&lt;br /&gt;
% tcp_server  -&amp;gt;  tcp_client&lt;br /&gt;
%&lt;br /&gt;
&lt;br /&gt;
% global variable for the object: we need this globally to&lt;br /&gt;
% use the object during the hook functions (e.g., _quick_send)&lt;br /&gt;
private variable _quick_obj = NULL;&lt;br /&gt;
% name of the receiver (quick_send) or the sender (quick_get)&lt;br /&gt;
private variable _quick_host = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
% greet_hook of quick_get (tcp_client): check the greet message of&lt;br /&gt;
% the server, which should be its hostname&lt;br /&gt;
define _quick_get_greet(c, greet) {&lt;br /&gt;
  if (greet == _quick_host) { return getenv(&amp;quot;HOST&amp;quot;); }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
define quick_get()&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
%!%+&lt;br /&gt;
%\function{quick_get}&lt;br /&gt;
%\synopsis{gets an SLang object sent from another machine}&lt;br /&gt;
%\usage{Any_Type quick_get(String_Type from_host);}&lt;br /&gt;
%\example&lt;br /&gt;
%    % receive an object from 'indus'&lt;br /&gt;
%    variable obj = quick_get(&amp;quot;indus&amp;quot;);&lt;br /&gt;
%\seealso{quick_send, tcp_client}&lt;br /&gt;
%!%-&lt;br /&gt;
{&lt;br /&gt;
  switch (_NARGS)&lt;br /&gt;
    { case 1: (_quick_host) = (); }&lt;br /&gt;
    { help(_function_name); return; }&lt;br /&gt;
&lt;br /&gt;
  variable client;&lt;br /&gt;
  % try to connect to the sender until a connection is established&lt;br /&gt;
  do {&lt;br /&gt;
    client = tcp_client(&lt;br /&gt;
      _quick_host;&lt;br /&gt;
      chatty = 0,&lt;br /&gt;
      greet_hook = &amp;amp;_quick_get_greet % use user-defined greet message (see above)&lt;br /&gt;
    );&lt;br /&gt;
    % client == 0 -&amp;gt; connection failed, e.g., server is not running&lt;br /&gt;
    if (typeof(client) == Integer_Type &amp;amp;&amp;amp; client == 0) { sleep(1); }&lt;br /&gt;
  } while (typeof(client) != Struct_Type);&lt;br /&gt;
  % connection is established&lt;br /&gt;
  if (typeof(client) == Struct_Type) {&lt;br /&gt;
    % receive the object&lt;br /&gt;
    client.config.chatty = 1; % enabled progress bar&lt;br /&gt;
    _quick_obj = client.receive();&lt;br /&gt;
    client.config.chatty = 0; % disable further messages&lt;br /&gt;
    % disconnect from the server&lt;br /&gt;
    ()=client.disconnect();&lt;br /&gt;
    % return the object&lt;br /&gt;
    return _quick_obj;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
% established_hook of quick_send (tcp_server): send the object and&lt;br /&gt;
% shut down the server afterwards&lt;br /&gt;
private define _quick_send(s, c) {&lt;br /&gt;
  c.config.chatty = 1; % temporarily enable progress bar&lt;br /&gt;
  ()=c.send(_quick_obj);&lt;br /&gt;
  ()=s.shutdown();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
% greet_hook of quick_send (tcp_server):&lt;br /&gt;
% 1) define the greet message to be sent to the client, which is&lt;br /&gt;
%    the server's hostname&lt;br /&gt;
% 2) check if the re-greet message is equal to the expected receiver&lt;br /&gt;
private define _quick_send_greet() {&lt;br /&gt;
  variable s, c, greet = NULL;&lt;br /&gt;
  switch (_NARGS)&lt;br /&gt;
    % send greet message&lt;br /&gt;
    { case 2:&lt;br /&gt;
      (s,c) = ();&lt;br /&gt;
      return getenv(&amp;quot;HOST&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    % check greet message&lt;br /&gt;
    { case 3:&lt;br /&gt;
      (s,c,greet) = ();&lt;br /&gt;
      if (greet == _quick_host) { return 1; }&lt;br /&gt;
      % greet not accepted -&amp;gt; trigger the shutdown of the server&lt;br /&gt;
      % after execution of its main loop &lt;br /&gt;
      ()=s.shutdown(; trigger);&lt;br /&gt;
      return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
define quick_send()&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
%!%+&lt;br /&gt;
%\function{quick_send}&lt;br /&gt;
%\synopsis{sends an SLang object to another machine}&lt;br /&gt;
%\usage{quick_send(String_Type to_host, Any_Type object);}&lt;br /&gt;
%\example&lt;br /&gt;
%    % send an array of doubles to 'ara'&lt;br /&gt;
%    quick_send(&amp;quot;ara&amp;quot;, Double_Type[10000]);&lt;br /&gt;
%\seealso{quick_get, tcp_server}&lt;br /&gt;
%!%-&lt;br /&gt;
{&lt;br /&gt;
  switch (_NARGS)&lt;br /&gt;
    { case 2: (_quick_host, _quick_obj) = (); }&lt;br /&gt;
    { help(_function_name); return; }&lt;br /&gt;
&lt;br /&gt;
  ()=tcp_server(;&lt;br /&gt;
    maxclients = 1,&lt;br /&gt;
    chatty = 0,&lt;br /&gt;
    greet_hook = &amp;amp;_quick_send_greet, % use user-defined greet message (see above)&lt;br /&gt;
    established_hook = &amp;amp;_quick_send  % send the object by this hook&lt;br /&gt;
  );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Niu</name></author>
	</entry>
</feed>