Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Witch! Witch! They'll burn ya! -- Hag, "Tomorrow is Yesterday", stardate unknown


devel / comp.lang.c / for() {} else {}

SubjectAuthor
* for() {} else {}fir
+* Re: for() {} else {}Lawrence D'Oliveiro
|`* Re: for() {} else {}fir
| `- Re: for() {} else {}fir
`* Re: for() {} else {}Kaz Kylheku
 `- Re: for() {} else {}fir

1
for() {} else {}

<uq134q$1uje1$1@i2pn2.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=32799&group=comp.lang.c#32799

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!.POSTED!not-for-mail
From: fir...@grunge.pl (fir)
Newsgroups: comp.lang.c
Subject: for() {} else {}
Date: Thu, 08 Feb 2024 00:18:53 +0100
Organization: i2pn2 (i2pn.org)
Message-ID: <uq134q$1uje1$1@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 7 Feb 2024 23:18:50 -0000 (UTC)
Injection-Info: i2pn2.org;
logging-data="2051521"; mail-complaints-to="usenet@i2pn2.org";
posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0";
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
X-Spam-Checker-Version: SpamAssassin 4.0.0
 by: fir - Wed, 7 Feb 2024 23:18 UTC

i slightly thinked on how socket programing shpuld look
like in c (in pseudocode) maybe something like this
(a bit in pseudocode)

main() //client
{ int id = connect("adress", port);

for(int i=0; i<100; i++) // repeat 100x 10ms wait on connection done
{
if(connected(id)) goto connected:
sleep(10);
}

non_connected:

exit("non connected");

connected:

for(;;)
{
int n = received_packets(id)
for(int i=0; i<n;i++)
{
char* data = recv(id);
printf("%s", data);

}
sleep(10);

}

}
and encountered a case where you would like to get
else clausule after for in c (not first time)

it is becouse if you get something to appear in loop
if it appear you can break and continue but if it will not
you will ned to do something else

and without this else clause you must use gotos, which is not
a big problem but it overally shows that this for may need
an else

(not to say its good idea as for else yet with break dont look to much
optimal probably but its sorta interesting notice i think

Re: for() {} else {}

<uq150q$1kr8u$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=32805&group=comp.lang.c#32805

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: for() {} else {}
Date: Wed, 7 Feb 2024 23:50:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <uq150q$1kr8u$4@dont-email.me>
References: <uq134q$1uje1$1@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 7 Feb 2024 23:50:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5894b09826b61230d924acc4bad71243";
logging-data="1731870"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cbwZcpja5VydFt1+zFMcU"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:sbBzO3+HXsYDiNv9oX/sbjtRVvc=
 by: Lawrence D'Oliv - Wed, 7 Feb 2024 23:50 UTC

On Thu, 08 Feb 2024 00:18:53 +0100, fir wrote:

> sleep(10);

What if packets arrive faster than that?

Re: for() {} else {}

<uq15v6$1umru$1@i2pn2.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=32807&group=comp.lang.c#32807

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!.POSTED!not-for-mail
From: fir...@grunge.pl (fir)
Newsgroups: comp.lang.c
Subject: Re: for() {} else {}
Date: Thu, 08 Feb 2024 01:07:06 +0100
Organization: i2pn2 (i2pn.org)
Message-ID: <uq15v6$1umru$1@i2pn2.org>
References: <uq134q$1uje1$1@i2pn2.org> <uq150q$1kr8u$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 8 Feb 2024 00:07:03 -0000 (UTC)
Injection-Info: i2pn2.org;
logging-data="2055038"; mail-complaints-to="usenet@i2pn2.org";
posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0";
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
X-Spam-Checker-Version: SpamAssassin 4.0.0
In-Reply-To: <uq150q$1kr8u$4@dont-email.me>
 by: fir - Thu, 8 Feb 2024 00:07 UTC

Lawrence D'Oliveiro wrote:
> On Thu, 08 Feb 2024 00:18:53 +0100, fir wrote:
>
>> sleep(10);
>
> What if packets arrive faster than that?
>
you see i mentioned my reasoning that packed queue must be crucial
to such incoming packets communication methods so alongside the recv
command to get one packet you would preferably get more functions
for thsi queue at least one that informs you how manty pockets on
queue there is

see in that pseudocode

for(;;)
{
int n = received_packets(id) // <--- here
for(int i=0; i<n;i++)
{
char* data = recv(id);
printf("%s", data);

}
sleep(10);

}

i think depending on case you would have such situations when you
wuould probably prefer to store number of packets and only them
read many of them - i dont know maybe wideo sttreaming or something
would use that ? (i got no experience in any socked programming)

instead how they done it in wideo streaming they got a cpu-bound intense
loop when they copy heavy thousand of packets into some array? then take
a break and render id ? (if so when they render packets probably will
also queue in some network device queue, or they always have
rendering thread separatelly to packet receiving thread?
i guess the packets are received by network card whuch has its own
processor probably soit dont need a separate thread i guess only
a piece of ram for a packet queue

Re: for() {} else {}

<20240207152511.373@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=32813&group=comp.lang.c#32813

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!nntp.comgw.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: for() {} else {}
Date: Thu, 8 Feb 2024 00:40:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <20240207152511.373@kylheku.com>
References: <uq134q$1uje1$1@i2pn2.org>
Injection-Date: Thu, 8 Feb 2024 00:40:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="163263dc92baed57fd9aed84cf1a8c15";
logging-data="1748514"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+q8ke+CstWARY/6UnDDdOh1eENgwBRMsA="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:O7xe2bcNewxc0kl3cWnC63j8Rk0=
 by: Kaz Kylheku - Thu, 8 Feb 2024 00:40 UTC

On 2024-02-07, fir <fir@grunge.pl> wrote:
> i slightly thinked on how socket programing shpuld look
> like in c (in pseudocode) maybe something like this
> (a bit in pseudocode)

https://www.youtube.com/watch?v=hE-thwqI3P4&t=48s

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: for() {} else {}

<uq183q$1upen$1@i2pn2.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=32814&group=comp.lang.c#32814

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!.POSTED!not-for-mail
From: fir...@grunge.pl (fir)
Newsgroups: comp.lang.c
Subject: Re: for() {} else {}
Date: Thu, 08 Feb 2024 01:43:40 +0100
Organization: i2pn2 (i2pn.org)
Message-ID: <uq183q$1upen$1@i2pn2.org>
References: <uq134q$1uje1$1@i2pn2.org> <uq150q$1kr8u$4@dont-email.me> <uq15v6$1umru$1@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 8 Feb 2024 00:43:38 -0000 (UTC)
Injection-Info: i2pn2.org;
logging-data="2057687"; mail-complaints-to="usenet@i2pn2.org";
posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0";
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
In-Reply-To: <uq15v6$1umru$1@i2pn2.org>
X-Spam-Checker-Version: SpamAssassin 4.0.0
 by: fir - Thu, 8 Feb 2024 00:43 UTC

fir wrote:
> Lawrence D'Oliveiro wrote:
>> On Thu, 08 Feb 2024 00:18:53 +0100, fir wrote:
>>
>>> sleep(10);
>>
>> What if packets arrive faster than that?
>>
> you see i mentioned my reasoning that packed queue must be crucial
> to such incoming packets communication methods so alongside the recv
> command to get one packet you would preferably get more functions
> for thsi queue at least one that informs you how manty pockets on
> queue there is
>
> see in that pseudocode
>
> for(;;)
> {
> int n = received_packets(id) // <--- here
> for(int i=0; i<n;i++)
> {
> char* data = recv(id);
> printf("%s", data);
>
> }
> sleep(10);
>
> }
>
> i think depending on case you would have such situations when you
> wuould probably prefer to store number of packets and only them
> read many of them - i dont know maybe wideo sttreaming or something
> would use that ? (i got no experience in any socked programming)
>
> instead how they done it in wideo streaming they got a cpu-bound intense
> loop when they copy heavy thousand of packets into some array? then take
> a break and render id ? (if so when they render packets probably will
> also queue in some network device queue, or they always have
> rendering thread separatelly to packet receiving thread?
> i guess the packets are received by network card whuch has its own
> processor probably soit dont need a separate thread i guess only
> a piece of ram for a packet queue

im not sure though how the server code would look like
(probably the server name here not quite fits as its rather
client who invites for connections, inviter/invitator maybe)

so if client connects() the invitator should invite()
and has a queue not only for packets but also for 'guests'

work_with_guest(int guest_id)
{ int tag = get_tag(guest_id); //tag firld in quests queue used to
note state of interaction

if(tag==0)
{
send(guest_id, "hello");
set_tag(guest_id,1);

}

//here also acces queue of guest incoming packets

}

main() //server
{ int id = invite( port);

for(;;)
{

int n=get_guest_queue_length(id)
for(int i=0; i<n;i++) //interract with all quests
{
work_with_guest(i);
}

sleep(5);
}

}

i would write it this way probably but the sockets that there are are
rather confusing and for now i dont know how to implement things like this

Re: for() {} else {}

<uq18mo$1uq3s$1@i2pn2.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=32815&group=comp.lang.c#32815

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!.POSTED!not-for-mail
From: fir...@grunge.pl (fir)
Newsgroups: comp.lang.c
Subject: Re: for() {} else {}
Date: Thu, 08 Feb 2024 01:53:47 +0100
Organization: i2pn2 (i2pn.org)
Message-ID: <uq18mo$1uq3s$1@i2pn2.org>
References: <uq134q$1uje1$1@i2pn2.org> <20240207152511.373@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 8 Feb 2024 00:53:45 -0000 (UTC)
Injection-Info: i2pn2.org;
logging-data="2058364"; mail-complaints-to="usenet@i2pn2.org";
posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0";
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
X-Spam-Checker-Version: SpamAssassin 4.0.0
In-Reply-To: <20240207152511.373@kylheku.com>
 by: fir - Thu, 8 Feb 2024 00:53 UTC

Kaz Kylheku wrote:
> On 2024-02-07, fir <fir@grunge.pl> wrote:
>> i slightly thinked on how socket programing shpuld look
>> like in c (in pseudocode) maybe something like this
>> (a bit in pseudocode)
>
> https://www.youtube.com/watch?v=hE-thwqI3P4&t=48s
>
dat is how you singing? i got no time for that

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor