[freebsd] multi-threaded server
Merhaba, Bu konuyu buraya gondermek dogrumu bilmiyorum ama liste uyelerinin bu konuda tecrubesi oldugunu dusunerek yaziyorum. Ben multi-threaded calisanbir TCP server yazmak istiyorum. Ve her threadin server bagli 100er client'in isiyle ugrasmasini istiyorum. Ekteki kodda shu ana kadar bu dusuncemi uygulamaya calistigim kodu gorebilirsiniz. Gelelim sorunlarima. - thread'e 1 client atandiktan sonra thread rutinindeki while'in donmesi duruyor. ama hala o baglanan client'tan gelen verileri okuyabiliyor. -socketin blocking oldugunu dusunerek nonblocking yaptigimda client'tan data geldikten sonra sonra tekrar okumaya calistigimda -1 aliyorum. -her thread'e 1er client atandiktan sonra baglanan clientlarin isleri yapilamiyor. yani recv ile gelen datayi alamiyorum. - thread rutinin icinde select(2) kullanmaya calistim fakat bu seferbagli clientlardan recv ile data alamiyorum. bos zamaniniz olursa, ilgilenirseniz sevinirim. nerede hata yapiyor olabilecegimi bir turlu cikartamadim... iyi calismalar, parahat #include stdio.h #include pthread.h #include sys/timeb.h #include sys/select.h #include sys/socket.h #include sys/types.h #include sys/wait.h #include netinet/in.h #include string.h #include fcntl.h #include signal.h #include errno.h #define MAX_CLIENT_PER_THREAD 100 #define MAX_THREAD 2 #define PORT 3355 int listenfd; int which_thread = 0; typedef struct { pthread_t tid; int tnumber; long client_count; int clients[MAX_CLIENT_PER_THREAD]; } Thread; pthread_cond_t new_connection_cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t new_connection_mutex = PTHREAD_MUTEX_INITIALIZER; Thread threads[MAX_THREAD]; void nonblock(int sockfd) { int opts; opts = fcntl(sockfd, F_GETFL); if(opts 0) { perror(fcntl(F_GETFL)\n); exit(1); } opts = (opts | O_NONBLOCK); if(fcntl(sockfd, F_SETFL, opts) 0) { perror(fcntl(F_SETFL)\n); exit(1); } } void *thread_init_func(void *arg) { int tid = (int) arg; fd_set fdset; int highfd = 2; int readsocks; int i; char buffer[1024]; int n; printf(thread %d created\n, tid); printf(sizeof thread.clients: %d\n, sizeof(threads[tid].clients)); memset( (int *) threads[tid].clients, 0, sizeof(threads[tid].clients)); while(1) { printf(thread %d running, client count: %d\n, tid, threads[tid].client_count); sleep(3); for(i = 0; i threads[tid].client_count; i++) { if(threads[tid].clients[i] != 0) { n = recv(threads[tid].clients[i], buffer, 1023, 0); if(n == 0) { threads[tid].clients[i] = 0; threads[tid].client_count--; printf(client %d closed connection 0\n, threads[tid].clients[i]); } else if(n 0) { threads[tid].clients[i] = 0; threads[tid].client_count--; printf(client %d closed connection -1\n, threads[tid].clients[i]); } else { printf(\n %d bytes received from %d\n, n, threads[tid].clients[i]); } } } /*FD_ZERO(fdset); for(i = 0; i threads[tid].client_count; i++) { if(threads[tid].clients[i] != 0) { FD_SET(threads[tid].clients[i], fdset); if(threads[tid].clients[i] highfd) highfd = threads[tid].clients[i]; } } readsocks = select(highfd+1, fdset, NULL, NULL, 0); if(readsocks 0) { perror(select\n); exit(1); } else if(readsocks == 0) { printf(.); } else { for(i = 0; i threads[tid].client_count; i++) { if(FD_ISSET(threads[tid].clients[i], fdset)) { n = recv(threads[tid].clients[i], buffer, 1023, 0);
[freebsd] ipnat
merhabalar ; kendi ic networkumdeki 3128 proxy ckslarn X routerinden degil de Y routerinden nasl ckarabilirim ipnat rdr uzerinde durdum ama yapamadm galiba :) engin
Re: [freebsd] multi-threaded server
Selam, Gayet alengirli bir sahaya ilk adiminizi atmis bulunmaktasiniz :) - thread'e 1 client atandiktan sonra thread rutinindeki while'in donmesi duruyor. ama hala o baglanan client'tan gelen verileri okuyabiliyor. while'in donmesi duruyor derken neyi kastediyorsunuz? while'dan mi cikiyor program takiliyor mu? 1. durumda kodun bir yerinde ya return ya da break vardir, ikinci durumda da soket blocking mode'da oldugu icin buffer'inda veri olmayan bir descriptor'da block olmustur. -socketin blocking oldugunu dusunerek nonblocking yaptigimda client'tan data geldikten sonra sonra tekrar okumaya calistigimda -1 aliyorum. errno ne? -her thread'e 1er client atandiktan sonra baglanan clientlarin isleri yapilamiyor. yani recv ile gelen datayi alamiyorum. recv ya hata doner, donmuyorsa da socket buffer'da veri yoktur. - thread rutinin icinde select(2) kullanmaya calistim fakat bu sefer bagli clientlardan recv ile data alamiyorum. Bence Ricahrd Stevens'in Unix Network Programming kitabini heen edinin ve initial kisimlarini okuyun. Ikinci tavsiyem de multithreaded bir server dizayni yerine, multiprocess ve shared memory, pipe, message queue gibi IPC mekanizmalarini kullan diginiz bir server dizayn edin. Multithreaded bir server programlamak, gerektirdigi dikkat ve istedigi uzmanliktan dolayi su an icin sizin icin bayagi basagrisi olabilir. Murat - Cikmak icin, e-mail: [EMAIL PROTECTED] Liste arsivi: http://lists.enderunix.org ve http://www.mail-archive.com/freebsd@lists.enderunix.org Turkiye'nin ilk FreeBSD kitabi: http://www.acikkod.com/freebsd.php
RE: [freebsd] ipnat
tam bilmiyorum ama boyle bir kural isinizi gorurmu bende o kadar prof degilim ama bu sekilde yaptigim da calisti add 00235 fwd192.168.1.1,3128 tcp from192.168.1.0/24 to 0.0.0.0/0 80 kolay gelsin abdullah From: Engin OZTURK [mailto:[EMAIL PROTECTED] Sent: 10 March 2005 13:04To: freebsd@lists.enderunix.orgSubject: [freebsd] ipnat merhabalar ; kendi ic networkumdeki 3128 proxy ckslarn X routerinden degil de Y routerinden nasl ckarabilirim ipnat rdr uzerinde durdum ama yapamadm galiba :) engin -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.7.1 - Release Date: 09/03/2005
Re: [freebsd] ipnat
ipnat ozur net belirtmemisim ama ipfilter icindi istemim - Original Message - From: Abdullah ZTRK (ENKAMOSCITY.COM) To: freebsd@lists.enderunix.org Sent: Thursday, March 10, 2005 12:27 PM Subject: RE: [freebsd] ipnat tam bilmiyorum ama boyle bir kural isinizi gorurmu bende o kadar prof degilim ama bu sekilde yaptigim da calisti add 00235 fwd192.168.1.1,3128 tcp from192.168.1.0/24 to 0.0.0.0/0 80 kolay gelsin abdullah From: Engin OZTURK [mailto:[EMAIL PROTECTED] Sent: 10 March 2005 13:04To: freebsd@lists.enderunix.orgSubject: [freebsd] ipnat merhabalar ; kendi ic networkumdeki 3128 proxy ckslarn X routerinden degil de Y routerinden nasl ckarabilirim ipnat rdr uzerinde durdum ama yapamadm galiba :) engin --No virus found in this outgoing message.Checked by AVG Anti-Virus.Version: 7.0.308 / Virus Database: 266.7.1 - Release Date: 09/03/2005
Re: [freebsd] multi-threaded server
ya uykusuzluktan galiba :D recv (man page-den okudugum kadariyla) nonblocking socketlerde bufferde birsey bulamayinca errno olarak EAGAIN donduruyormus bende socketi kapatiyormusum errno'ya dikkatimi cektiginiz icin cok tesekkur ederim Murat bey pratikte denemek kaldi... - Original Message - From: Murat Balaban [EMAIL PROTECTED] To: freebsd@lists.enderunix.org Sent: Thursday, March 10, 2005 12:25 PM Subject: Re: [freebsd] multi-threaded server Selam, Gayet alengirli bir sahaya ilk adiminizi atmis bulunmaktasiniz :) - thread'e 1 client atandiktan sonra thread rutinindeki while'in donmesi duruyor. ama hala o baglanan client'tan gelen verileri okuyabiliyor. while'in donmesi duruyor derken neyi kastediyorsunuz? while'dan mi cikiyor program takiliyor mu? 1. durumda kodun bir yerinde ya return ya da break vardir, ikinci durumda da soket blocking mode'da oldugu icin buffer'inda veri olmayan bir descriptor'da block olmustur. -socketin blocking oldugunu dusunerek nonblocking yaptigimda client'tan data geldikten sonra sonra tekrar okumaya calistigimda -1 aliyorum. errno ne? -her thread'e 1er client atandiktan sonra baglanan clientlarin isleri yapilamiyor. yani recv ile gelen datayi alamiyorum. recv ya hata doner, donmuyorsa da socket buffer'da veri yoktur. - thread rutinin icinde select(2) kullanmaya calistim fakat bu sefer bagli clientlardan recv ile data alamiyorum. Bence Ricahrd Stevens'in Unix Network Programming kitabini heen edinin ve initial kisimlarini okuyun. Ikinci tavsiyem de multithreaded bir server dizayni yerine, multiprocess ve shared memory, pipe, message queue gibi IPC mekanizmalarini kullan diginiz bir server dizayn edin. Multithreaded bir server programlamak, gerektirdigi dikkat ve istedigi uzmanliktan dolayi su an icin sizin icin bayagi basagrisi olabilir. Murat - Cikmak icin, e-mail: [EMAIL PROTECTED] Liste arsivi: http://lists.enderunix.org ve http://www.mail-archive.com/freebsd@lists.enderunix.org Turkiye'nin ilk FreeBSD kitabi: http://www.acikkod.com/freebsd.php - Cikmak icin, e-mail: [EMAIL PROTECTED] Liste arsivi: http://lists.enderunix.org ve http://www.mail-archive.com/freebsd@lists.enderunix.org Turkiye'nin ilk FreeBSD kitabi: http://www.acikkod.com/freebsd.php
[freebsd] qsheff wblist
merhaba , bir yerde gozden kacirdigim bir yer mi var diye sizlere danismak istedim. qsheff de wblist icinde tanimlama yaparken bir domainden gelen mailleri safe olarak tanimlayamiyormuyuz ? qsheff.wblist iine ACCEPT @domain.com yazdigimizda normalde domain.com uzantili mailleri spam filtrelerine uramadan gemesi gerekli deil mi ? bende takld da... ne zaman ki mail adresini tam yazdm o zaman sorun zld.. aynsn domain iin yapamyor muyuz ? iyi almalar - Cikmak icin, e-mail: [EMAIL PROTECTED] Liste arsivi: http://lists.enderunix.org ve http://www.mail-archive.com/freebsd@lists.enderunix.org Turkiye'nin ilk FreeBSD kitabi: http://www.acikkod.com/freebsd.php
Re: [freebsd] Re: maillog yorumu
Merhabalar, Adamlar hakli tabi. TT'a ait DNS sunucular hic adam gibi calismadi neredeyse. Internet kullanicilari da ODTU DNS sunucularina yuklendi demek. TT internet hizmetlerini ne zaman hal yola sokacak merak ediyorum dogrusu. Simdi bir de haber dolasiyor ortada, ADSL hizlarini ucuzlatarak arttirmayi planliyormus yine TT. En dusuk hiz 512 Kbps olacakmis. En yuksek hizi da 2048 Kbps'den 4096 Kbps'ye cikaracaklarmis. Internet altyapisini desteklemeden bunu yaparlarsa durum ne olur tahmin bile edilemez sanirim. Saygilarimla.. --- Huseyin YUCE [EMAIL PROTECTED] wrote: Merhaba , Ulak-Teknik Listesinden alintidir. Uzun zamandir ODTU kampusunde bulunan DNS servisinde bazi degisiklikler yapilmistir. Daha once tum sorgulamalara acik olan DNS sunucularimiza cok yogun sekilde istek gelmektedir. Yapilan degisiklik ile 144.122.0.0/16 disindan gelen sorgulamalara 14/03/2005 saat 9:00'dan sonra cevap verilmeyecektir. Dolayisi ile kendi DNS serverlarini kullanmayan kisi/kurumlarin bundan sonra baska bir DNS servisi kullanmalari gerekmektedir. DNS sunucularindan gelecek sorgulamalara gerekli sekilde cevap verilmeye devam edilecektir. Niye boyle bir mesaji sizlere gonderdigimiz kismi ise, kendi loglarimiz incelendiginde pekcok Internet kullanicisi bizim DNS sunucu adreslerimizi kullanmaktadir. Bundan sonra kendilerine buyuk bir cogunlukla cevap donulmeyecektir. Bundan dolayi Internet baglantimiz calismiyor sikayetleri gelebilir. Lutfen tum ayarlarinizi kendi servis aldiginiz DNS sunucularinizi gosterecek sekilde degistiriniz. - Thursday, March 10, 2005, 12:22:29 AM, þunu yazdýnýz: BS bir de bugunlerde ttnet'in ve ulaknet'in (dolaysiyla odtu nun, dolaysiyla BS tum turkiye'nin) sac bas yolduran dns problemleri var. Bu nedenle emailler BS gonderilirken bazen karsi tarafa ulasamiyor. sebep DNS. BS Baris Simsek BS http://www.enderunix.org/simsek =---= 10.03.2005 - 09:17:23 =---= Ogr. Gor. Huseyin YUCE Marmara Üniversitesi Bilisim Merkezi Sorumlusu e-posta : [EMAIL PROTECTED] web : http://www.yuce.web.tr =---= - Cikmak icin, e-mail: [EMAIL PROTECTED] Liste arsivi: http://lists.enderunix.org ve http://www.mail-archive.com/freebsd@lists.enderunix.org Turkiye'nin ilk FreeBSD kitabi: http://www.acikkod.com/freebsd.php __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ - Cikmak icin, e-mail: [EMAIL PROTECTED] Liste arsivi: http://lists.enderunix.org ve http://www.mail-archive.com/freebsd@lists.enderunix.org Turkiye'nin ilk FreeBSD kitabi: http://www.acikkod.com/freebsd.php
[freebsd] freebsd 5.3 release 'den 5.3 stable ve gnome 2.8 için izlenmesi gereken yok..(?)
arkadalar selam, ben freebsd i desktop ortamnda kullanmak istiyorum bunun iin daha nce 2.6 y falan kullandm fakat freebsd nin sitesinden indirdiim upgrade script i ile falan sorun yaadm, herneyse sfrdan kurulum yapacam uan. sisteme perl python falan ykleyeyim mi?.. sistemi release ten ksa yoldan stable a evirip gnome 2.8 i yklemek istiyorum =). daha nce karlatm hata saysn bi ben bilirim heralde.. birde bu make world olay iin cvsup la sistemi upgrade ettikten sonramyd, tecrbelerinzi paylarsanz ok sevineceim.. teekkrler - Cikmak icin, e-mail: [EMAIL PROTECTED] Liste arsivi: http://lists.enderunix.org ve http://www.mail-archive.com/freebsd@lists.enderunix.org Turkiye'nin ilk FreeBSD kitabi: http://www.acikkod.com/freebsd.php
[freebsd] freebsd 5.3 release i stable kullanmak ve sorunsuz gnome 2.8 kurulumu (?)
arkadalar selam, ben freebsd i desktop ortamnda kullanmak istiyorum bunun iin daha nce 2.6 y falan kullandm fakat freebsd nin sitesinden indirdiim upgrade script i ile falan sorun yaadm, herneyse sfrdan kurulum yapacam uan. sisteme perl python falan ykleyeyim mi?.. sistemi release ten ksa yoldan stable a evirip gnome 2.8 i yklemek istiyorum =). daha nce karlatm hata saysn bi ben bilirim heralde.. birde bu make world olay iin cvsup la sistemi upgrade ettikten sonramyd, tecrbelerinzi paylarsanz ok sevineceim.. teekkrler - Cikmak icin, e-mail: [EMAIL PROTECTED] Liste arsivi: http://lists.enderunix.org ve http://www.mail-archive.com/freebsd@lists.enderunix.org Turkiye'nin ilk FreeBSD kitabi: http://www.acikkod.com/freebsd.php
Re: [freebsd] freebsd 5.3 release i stable kullanmak ve sorunsuz gnome 2.8 kurulumu (?)
Gnome icin dagitilan upgrade scriptini hangi asamada calistirdiniz? Su adimlari takip ederek denermisiniz 1)FreeBSD 5.3 kurulur 2)CVSup ile port agaci guncellenir 3)http://www.freebsd.org/gnome/gnome_upgrade.sh adresindeki betik root haklari ile calistirilir http://www.freebsd.org/gnome/docs/faq2.html adreside yardimci olabilir. On Thu, 2005-03-10 at 21:42 +0200, A OKAN YKSEL wrote: arkadalar selam, ben freebsd i desktop ortamnda kullanmak istiyorum bunun iin daha nce 2.6 y falan kullandm fakat freebsd nin sitesinden indirdiim upgrade script i ile falan sorun yaadm, herneyse sfrdan kurulum yapacam uan. sisteme perl python falan ykleyeyim mi?.. sistemi release ten ksa yoldan stable a evirip gnome 2.8 i yklemek istiyorum =). daha nce karlatm hata saysn bi ben bilirim heralde.. birde bu make world olay iin cvsup la sistemi upgrade ettikten sonramyd, tecrbelerinzi paylarsanz ok sevineceim.. teekkrler - Cikmak icin, e-mail: [EMAIL PROTECTED] Liste arsivi: http://lists.enderunix.org ve http://www.mail-archive.com/freebsd@lists.enderunix.org Turkiye'nin ilk FreeBSD kitabi: http://www.acikkod.com/freebsd.php smime.p7s Description: S/MIME cryptographic signature
[freebsd] sendmail ile antivir
merhaba bizim mail server'ýmýz freebsd 5.3 release ve sendmail kullanýyor. üzerine acilen bir antivirüs programý kurmam gerekiyor. ancak bu konuda pek bir bilgim yok. önerebileceðiniz antivirüs programý var mý? ve nasýl kuracaðým konusunda bana yardýmcý olabilir misiniz? iyi çalýþmalar... Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard.
Re: [freebsd] sendmail ile antivirüs
Merhaba, Benim size onerecegim, mimedefang + spamassassin ve clamav uclusunu kullanmanizdir. Simdiye kadar kurdugum cogu yerde hic sorunla karsilasilmadan kullanilabilen hizli ve etkili bir sistem.. Size bu programin nasil kurulacagini gosteren asagidaki ingilizce dokumani verebilirim.. iyi calismalar. Murat Ustuntas = Mail Server Filtering by Michael W. Lucas 04/01/2004 Most of what arrives at my mail servers is unwanted: viruses, spam, and executable garbage. Even if you're running something other than Windows on the desktop, the sudden appearance of a new virus can overwhelm your inbox. If you're an administrator, your users likely aren't as reliable about not clicking on attachments as we'd all like. Combined with the flood of spam and random garbage, putting a mail server on the Internet without filtering is like covering yourself with barbecue sauce and breaking into the Charity Home for Badgers with Rabies. Decent spam and virus protection measures can save you a lot of time and effort. While the systems I use for this article are FreeBSD, the tools and techniques will work on any UNIX-like operating system running modern Sendmail. Many commercial vendors provide garbage mail protection for Sendmail, but if I go around buying software then I'm never going to be able to afford that 17" laptop. Instead, I use MIMEDefang for generic content handling, SpamAssassin to identify unwanted bulk mail, and ClamAV to reject viruses. This combination eliminates almost all unwanted mail, while letting the good stuff through. Sendmail(8) provides a milter (or mail filter) API for third-party programs. This means that it's fairly straightforward to add functionality to Sendmail with very little overhead. We can attach MIMEDefang to Sendmail via milter. MIMEDefang can call both SpamAssassin and ClamAV. To make this work, however, you must install and configure the various programs in the correct order. Install the ClamAV Antivirus Scanner Install ClamAV from /usr/ports/security/clamav by running make install. Do not run make clean yet! The work subdirectory contains some sample viruses that we'll use to confirm that the program works correctly. The port will install the main virus scanner, clamd(8), a command-line console clamscan(1), a preliminary virus signature database, and an assortment of documentation and ancillary programs. Under normal operation, the clamd(8) virus scanner should be running at all times. Other programs can send files to clamd(8) to learn if they are infected. Start clamd from the command line. Though it requires configuration, we'll be able to test it before doing our custom setup. While you're still in the port directory, use the console command to scan the work subdirectory for viruses. # clamscan -r -l testoutput.txt The -r recursively scans the current directory and the -l tells clamscan to log the output to the text file testoutput.txt. When you run this command, clamscan will check every file under the current directory for viruses and print out its status. A condensed version of the results, containing only the path to the infected files and a list of statistics, will appear in the logfile. For ClamAV 0.65, this test should discover five infected files. Now, let's configure ClamAV to cooperate with MIMEDefang. The main configuration file is /usr/local/etc/clamav.conf. Many of the settings are tweakable as you desire. See the clamav.conf(5) man page for all of the options. The most important change is that you should set the user to mailnull, the same user that Sendmail and MIMEDefang run as. #User clamav User mailnull By changing this setting, you also need to change the permissions on the various directories to which ClamAV writes. # chown -R mailnull:mailnull /var/run/clamav/ # chown -R mailnull:mailnull /var/log/clamav/ Now that you have a basic virus scanner, you can update your virus definitions. Virus definitions are maintained by volunteers from around the world. When a major new virus hits, you can expect to see a definition available within hours. As I write this, the ClamAV database has signatures for 10,131 popular viruses. First, run freshclam as root to confirm that your software can successfully contact one of the virus signature mirrors and download the latest definitions. You should see the program check the freshness of main.cvd and daily.cvd before returning to the command line. Once you know the update process works, enable the freshclam daemon to check for updates. There is one minor complication, however; freshclam runs as clamav and clamd runs as mailnull, so by default you won't be able to write freshclam reports in the clamav log directory. While you can muck around with file and directory ownership or change the user that freshclam runs as, the simplest thing to do is put your freshclam log elsewhere. When you're done, your /etc/rc.conf should have the following new lines: clamav_clamd_enable="YES" clamav_freshclam_enable="YES"