Monday, October 4, 2021

Digest for comp.programming.threads@googlegroups.com - 8 updates in 4 topics

Branimir Maksimovic <branimir.maksimovic@icloud.com>: Oct 03 07:07PM

import Foundation
 
let s = Server();
s.start()
var semaphore = 4
class Server {
init() {
if (CommandLine.argc > 1) {
tmpSvcPort = Int(CommandLine.arguments[1]) ?? 0
if (tmpSvcPort > 0){ servicePort = String(tmpSvcPort) }
}
}
var ende = false
var tmpSvcPort: Int = 0
var servicePort = "1234"
class Worker:Thread{
weak var parent: Server! = nil
init(_ fd:Int32){
self.fd = fd
}
deinit {
semaphore += 1
close(fd)
}
override func main(){
let MTU = 65536
let buffer = UnsafeMutablePointer<CChar>.allocate(capacity:MTU)
defer {
buffer.deallocate()
}
var count = 1
while (count > 0) {
count -= 1
let readResult = read(fd, buffer, MTU)
 
if (readResult == 0) {
break; // end of file
} else if (readResult == -1) {
print("Error reading form client\(fd) - \(errno)")
break; // error
} else {
let strResult =
String(cString: buffer)
let numbers = strResult.components(separatedBy: " ")
var sum = 0
if numbers.count > 1 {
if numbers[0].lowercased() == "quit" {
parent.ende = true
continue
} else {
let num1 = Int(numbers[0]) ?? 0
let num2 = Int(numbers[1]) ?? 0
sum = num1 + num2
}
}
print("Received form client(\(fd)): \(strResult)")
let out = String(format:"suma %d\n",sum)
let _ = out.withCString {
write(fd, $0, out.count)
}
}
}
}
var fd: Int32
}
func start() {
print("Server starting...")
 
let socketFD = socket(AF_INET6, //Domain [AF_INET,AF_INET6, AF_UNIX]
SOCK_STREAM, //Type [SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW]
IPPROTO_TCP //Protocol [IPPROTO_TCP, IPPROTO_SCTP, IPPROTO_UDP, IPPROTO_DCCP]
)//Return a FileDescriptor -1 = error
if socketFD == -1 {
print("Error creating BSD Socket")
return
}
 
var hints = addrinfo(
ai_flags: AI_PASSIVE, // Assign the address of the local host to the socket structures
ai_family: AF_UNSPEC, // Either IPv4 or IPv6
ai_socktype: SOCK_STREAM, // TCP
ai_protocol: 0,
ai_addrlen: 0,
ai_canonname: nil,
ai_addr: nil,
ai_next: nil)
 
var servinfo: UnsafeMutablePointer<addrinfo>? = nil
let addrInfoResult = getaddrinfo(
nil, // Any interface
servicePort, // The port on which will be listenend
&hints, // Protocol configuration as per above
&servinfo)
 
if addrInfoResult != 0 {
print("Error getting address info: \(errno)")
return
}
 
let bindResult = bind(socketFD, servinfo!.pointee.ai_addr, socklen_t(servinfo!.pointee.ai_addrlen))
 
if bindResult == -1 {
print("Error binding socket to Address: \(errno)")
return
}
 
let listenResult = listen(socketFD, //Socket File descriptor
128 // The backlog argument defines the maximum length the queue of pending connections may grow to
)
/**
let flags = fcntl(socketFD,F_GETFL)
let _ = fcntl(socketFD,F_SETFL,flags | O_NONBLOCK)
*/
 
if listenResult == -1 {
print("Error setting our socket to listen")
return
}
while (!self.ende) {
var addr = sockaddr()
var addr_len :socklen_t = 0
while (true) {
while(semaphore > 4){}
print("About to accept")
let accFD = accept(socketFD, &addr, &addr_len)
semaphore -= 1
if (accFD > 0){
/** let flags = fcntl(accFD,F_GETFL)
let _ = fcntl(accFD,F_SETFL,flags & ~O_NONBLOCK)
*/
print("Accepted new client with file descriptor: \(accFD)")
let handle = Worker(accFD);
handle.start()
} else {
print("Error accepting connection")
}
}
}
}
 
}
 
 
--
 
7-77-777
Evil Sinner!
to weak you should be meek, and you should brainfuck stronger
https://github.com/rofl0r/chaos-pp
Branimir Maksimovic <branimir.maksimovic@icloud.com>: Oct 04 04:30AM

On 2021-10-03, Branimir Maksimovic <branimir.maksimovic@icloud.com> wrote:
 
import Foundation
signal(SIGPIPE,SIG_IGN)
let s = Server();
s.start()
var semacnt:Int? = nil
class Server {
init() {
if (CommandLine.argc > 1) {
tmpSvcPort = Int(CommandLine.arguments[1]) ?? 0
if (tmpSvcPort > 0){ servicePort = String(tmpSvcPort) }
}
semacnt! = 0
}
var ende = false
var tmpSvcPort: Int = 0
var servicePort = "1234"
class Worker:Thread{
weak var parent: Server! = nil
init(_ fd:Int32){
self.fd = fd
semacnt! += 1
}
deinit {
close(fd)
semacnt! -= 1
}
override func main(){
let MTU = 65536
let buffer = UnsafeMutablePointer<CChar>.allocate(capacity:MTU)
defer {
buffer.deallocate()
}
var count = 1
while (count > 0) {
count -= 1
let readResult = read(fd, buffer, MTU)
 
if (readResult == 0) {
break; // end of file
} else if (readResult == -1) {
print("Error reading form client\(fd) - \(errno)")
break; // error
} else {
let strResult =
String(cString: buffer)
let numbers = strResult.components(separatedBy: " ")
var sum = 0
if numbers.count > 1 {
if numbers[0].lowercased() == "quit" {
parent.ende = true
continue
} else {
let num1 = Int(numbers[0]) ?? 0
let num2 = Int(numbers[1]) ?? 0
sum = num1 + num2
}
}
print("Received form client(\(fd)): \(strResult)")
let out = String(format:"suma %d\n",sum)
let _ = out.withCString {
/**let flags = fcntl(fd,F_GETFL)
let _ = fcntl(fd,F_SETFL,flags | O_NONBLOCK)
*/
while(semacnt! > 128){usleep(100)} // we don't want to attack too many
write(fd, $0, out.count)
 
}
}
}
}
var fd: Int32
}
func start() {
print("Server starting...")
 
let socketFD = socket(AF_INET6, //Domain [AF_INET,AF_INET6, AF_UNIX]
SOCK_STREAM, //Type [SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW]
IPPROTO_TCP //Protocol [IPPROTO_TCP, IPPROTO_SCTP, IPPROTO_UDP, IPPROTO_DCCP]
)//Return a FileDescriptor -1 = error
if socketFD == -1 {
print("Error creating BSD Socket")
return
}
 
var hints = addrinfo(
ai_flags: AI_PASSIVE, // Assign the address of the local host to the socket structures
ai_family: AF_UNSPEC, // Either IPv4 or IPv6
ai_socktype: SOCK_STREAM, // TCP
ai_protocol: 0,
ai_addrlen: 0,
ai_canonname: nil,
ai_addr: nil,
ai_next: nil)
 
var servinfo: UnsafeMutablePointer<addrinfo>? = nil
let addrInfoResult = getaddrinfo(
nil, // Any interface
servicePort, // The port on which will be listenend
&hints, // Protocol configuration as per above
&servinfo)
 
if addrInfoResult != 0 {
print("Error getting address info: \(errno)")
return
}
setsockopt(socketFD,SOL_SOCKET,SO_REUSEADDR,servinfo!.pointee.ai_addr, socklen_t(servinfo!.pointee.ai_addrlen))
let bindResult = bind(socketFD, servinfo!.pointee.ai_addr, socklen_t(servinfo!.pointee.ai_addrlen))
 
if bindResult == -1 {
print("Error binding socket to Address: \(errno)")
return
}
 
let listenResult = listen(socketFD, //Socket File descriptor
128 // The backlog argument defines the maximum length the queue of pending connections may grow to
)
 
/** let flags = fcntl(socketFD,F_GETFL)
let _ = fcntl(socketFD,F_SETFL,flags | O_NONBLOCK)
*/
 
if listenResult == -1 {
print("Error setting our socket to listen")
return
}
while (!self.ende) {
var addr = sockaddr()
var addr_len :socklen_t = 0
while (true) {
print("About to accept")
let accFD = accept(socketFD, &addr, &addr_len)
if (accFD > 0){
print("Accepted new client with file descriptor: \(accFD)")
let handle = Worker(accFD);
handle.start()
} else {
print("Error accepting connection")
usleep(100)
}
}
}
}
 
}
 
--
 
7-77-777
Evil Sinner!
to weak you should be meek, and you should brainfuck stronger
https://github.com/rofl0r/chaos-pp
Branimir Maksimovic <branimir.maksimovic@icloud.com>: Oct 03 07:05PM

import Foundation
 
@main
struct Main{
static var factor : Int = 8;
actor A{
static func phi(_ nn : Int)->Int {
var n = nn
var m = n;
if n % 2 == 0 {
m /= 2;
while n % 2 == 0 {
n /= 2;
}
}
var i = 3;
while (i*i <= n) {
if n % i == 0 {
m /= i;
m *= (i-1);
while n % i == 0 {
n /= i
}
}
i += 2
}
if n > 1 {
m /= n;
m *= (n-1)
}
return m
}
static func f(_ n:Int)->Int {
if n & 1 == 0 { return 0 }
 
return phi(n)
}
func g(_ n : Int)async->Int{
var sum = 0
await withTaskGroup(of: Int.self) { group in
for j in 0..<factor {
group.addTask{
var i = j + 1
var sum = 0
print("starting")
while i <= n {
sum += A.f(i)
i += factor
}
return sum
}
}
for await result in group {
sum+=result
}
}
return sum
}
}
static func main()async{
let task = Process()
task.executableURL = URL(fileURLWithPath: "/usr/sbin/sysctl")
task.arguments = ["hw.ncpu"]
let out = Pipe()
task.standardOutput = out
let res: ()? = try? task.run()
if let _ = res {
let outputData = out.fileHandleForReading.readDataToEndOfFile()
let s = String(decoding: outputData, as: UTF8.self)
print("got from sysctl ",s)
let sep = CharacterSet(charactersIn: " \n")
let components = s.components(separatedBy: sep)
factor = Int(components[1]) ?? 4
}
print("factor ",factor)
print("entering main")
let a = A()
await print(a.g(100))
await print(a.g(Int(5e8)))
}
}
 
 
--
 
7-77-777
Evil Sinner!
to weak you should be meek, and you should brainfuck stronger
https://github.com/rofl0r/chaos-pp
Branimir Maksimovic <branimir.maksimovic@icloud.com>: Oct 03 07:04PM

import Foundation
 
@main
struct Main{
static var i:Int = 0
static func f()->Int{
i += 1
let j = i
print("async ",j)
return j
}
actor A{
var future:[Int] = Array(repeating: 0, count: 10)
func set(_ index:Int,_ val:Int){
future[index] = val
}
func get(_ index:Int)->Int{
return future[index]
}
func run()async{
await withTaskGroup(of: Void.self) { group in
for i in 0..<10 {
group.addTask{
print("starting")
await self.set(i, f())
}
}
}
}
func collect(){
for i in 0..<10 {
print("result ",get(i))
}
}
}
static func main()async{
print("entering main")
let a = A()
await a.run()
await a.collect()
}
}
 
 
--
 
7-77-777
Evil Sinner!
to weak you should be meek, and you should brainfuck stronger
https://github.com/rofl0r/chaos-pp
Amine Moulay Ramdane <aminer68@gmail.com>: Oct 03 10:18AM -0700

Hello,
 
 
Scientists discover 14 genes that cause obesity
 
"The discovery of genes that directly cause obesity could pave the way for treatments for a condition that affects more than 40% of American adults."
 
Read more here:
 
https://www.sciencedaily.com/releases/2021/10/211001100432.htm
 
And read the following news:
 
And Sweat Away Fat to Fix Obesity
 
"The University of Pennsylvania looking for a diabetes treatment have accidentally developed an innovative, even revolutionary treatment for weight loss. Treating obese mice with the cytokine known as TSLP led to significant abdominal fat and weight loss compared to controls.."
 
Read more here:
 
https://www.nextbigfuture.com/2021/09/sweat-away-fat-to-fix-obesity.html#more-173134
 
More of my philosophy about Metformin and more..
 
I am a white arab from Morocco, and i think i am smart since i have also
invented many scalable algorithms and algorithms..
 
I invite you to read carefully all my following thoughts and news:
 
Is metformin a wonder drug?
 
Metformin's benefits may extend far beyond diabetes, since it prevents cardiovascular disease and it lowers the risk of cancer(read the proof here: https://cancerci.biomedcentral.com/articles/10.1186/s12935-021-01921-z), and it slows aging, prevent age-related disease, and increase lifespan.
 
Read more here:
 
https://www.health.harvard.edu/blog/is-metformin-a-wonder-drug-202109222605
 
And more precision about I3C (Indole-3-carbinol) and cancer..
 
I have just read the following article, i invite you to read it:
 
Broccoli and Brussels sprouts: Cancer foes
 
https://news.harvard.edu/gazette/story/2019/05/beth-israel-researchers-uncover-anti-cancer-drug-mechanism-in-broccoli/
 
But i think that the above article is not speaking about the following
research that says the following about I3C (Indole-3-carbinol):
 
"In vivo studies showed that I3C inhibits the development of different
cancers in several animals when given before or in parallel to a
carcinogen. However, when I3C was given to the animals after the
carcinogen, I3C promoted carcinogenesis. This concern regarding the
long-term effects of I3C treatment on cancer risk in humans resulted in
some caution in the use of I3C as a dietary supplement in cancer
management protocols"
 
Read more here to notice it:
 
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5989150/
 
So i don't advice to take I3C(Indole-3-carbinol) as a dietary
supplement, because I3C(Indole-3-carbinol) can reduce the risk of cancer
, but still you can have cancer even if you take I3C(Indole-3-carbinol)
, so it is dangerous to take I3C(Indole-3-carbinol) because taking
I3C(Indole-3-carbinol) after the carcinogen promotes carcinogenesis(read
my writing above to notice it).
 
Antiaging Gene Therapies Extend Lifespan of Mice by 41%
 
"If humans experienced the same antiaging effect as the mice then humans would live to a median age of 100 with these treatments."
 
Read more here:
 
https://www.nextbigfuture.com/2021/07/antiaging-gene-therapies-extend-lifespan-of-mice-by-41.html#more-171929
 
And read carefully my following thoughts about Nanotechnology and about Exponential Progress:
 
https://groups.google.com/g/alt.culture.morocco/c/mjE_2AG1TKQ
 
 
Thank you,
Amine Moulay Ramdane.
Bonita Montero <Bonita.Montero@gmail.com>: Oct 03 08:16PM +0200

Am 03.10.2021 um 19:18 schrieb Amine Moulay Ramdane:
 
> More of my philosophy about Metformin and more..
 
> I am a white arab from Morocco, and i think i am smart since i have also
> invented many scalable algorithms and algorithms..
 
You're an idiot !
Branimir Maksimovic <branimir.maksimovic@icloud.com>: Oct 03 06:56PM


> More of my philosophy about Metformin and more..
 
> I am a white arab from Morocco, and i think i am smart since i have also
> invented many scalable algorithms and algorithms..
 
We know that, bu you are black as dirt :P
Why you are LYING?!
 
> I have just read the following article, i invite you to read it:
 
> Broccoli and Brussels sprouts: Cancer foes
 
ahahahhahahahahahahahhahahahahahahhahahah
 
 
> But i think that the above article is not speaking about the following
> research that says the following about I3C (Indole-3-carbinol):
 
> https://groups.google.com/g/alt.culture.morocco/c/mjE_2AG1TKQ
 
:P
 
> Thank you, Amine Moulay Ramdane.
iAmine! M;ulq, Radmane !
 
--
 
7-77-777
Evil Sinner!
to weak you should be meek, and you should brainfuck stronger
https://github.com/rofl0r/chaos-pp
Branimir Maksimovic <branimir.maksimovic@icloud.com>: Oct 03 06:57PM

> Am 03.10.2021 um 19:18 schrieb Amine Moulay Ramdane:
 
> You're an idiot !
 
Of course, stupid as a brick :P
 
--
 
7-77-777
Evil Sinner!
to weak you should be meek, and you should brainfuck stronger
https://github.com/rofl0r/chaos-pp
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.programming.threads+unsubscribe@googlegroups.com.

No comments: