忍者ブログ
  • 2018.09
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 2018.11
[PR]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

【2018/10/24 06:05 】 |
                                    
重複して始まらないBeginAcceptTcpClient その2
BeginAcceptTcpClientについて、スレッドIDを取得してみた。
子スレッドは2つまで?うむむ。

ソース
Imports System.Net.Sockets

Imports System.Threading


Public Class TestNet
    ' Thread signal.
    Public Shared tcpClientConnected As New ManualResetEvent(False)
    Public Shared Sub dp(s As String, ParamArray a() As String)
        SyncLock tcpClientConnected
            Debug.Print(s, a)
        End SyncLock
    End Sub
    Public Sub TestServerAndClient()
        Dim client As Thread

        Dim procClient As Action(Of Byte) _
            = Sub(aByte As Byte)
                  client = New Thread(New ThreadStart(Sub()
                                                          Thread.Sleep(1000)

                                                          Dim sckClient As TcpClient
                                                          sckClient = New TcpClient()
                                                          dp("cl connect {0}-{1}", Now, aByte)
                                                          sckClient.Connect(Net.IPAddress.Loopback, 9000)
                                                          sckClient.GetStream().WriteByte(aByte)
                                                      End Sub))
                  client.Start()
              End Sub
        procClient(0)
        procClient(1)
        procClient(2)
        procClient(3)
        procClient(4)

        Dim tl As TcpListener = New TcpListener(Net.IPAddress.Loopback, 9000)
        tl.Start(3)
        DoBeginAcceptTcpClient(tl)
        dp("sv connect")
        DoBeginAcceptTcpClient(tl)
        dp("sv connect")
        DoBeginAcceptTcpClient(tl)
        dp("sv connect")
        DoBeginAcceptTcpClient(tl)
        dp("sv connect")
        DoBeginAcceptTcpClient(tl)
        dp("sv connect")
    End Sub

    Public Shared Sub DoBeginAcceptTcpClient(listener As TcpListener)
        tcpClientConnected.Reset()
        listener.BeginAcceptTcpClient(New AsyncCallback(AddressOf DoAcceptTcpClientCallback), listener)
        tcpClientConnected.WaitOne()
    End Sub


    Public Shared Sub DoAcceptTcpClientCallback(ar As IAsyncResult)
        Dim listener As TcpListener = CType(ar.AsyncState, TcpListener)
        Dim client As TcpClient = listener.EndAcceptTcpClient(ar)
        tcpClientConnected.Set()
        Dim bt As Byte = client.GetStream().ReadByte()
        dp("child accept {0}-{1} Start {2}", Now, bt, Thread.CurrentThread.ManagedThreadId)
        Thread.Sleep(3000)
        dp("child accept {0}-{1} End", Now, bt)
        client.GetStream().Close()
    End Sub

End Class


cl connect 2018/03/21 5:46:56-1
cl connect 2018/03/21 5:46:56-2
cl connect 2018/03/21 5:46:56-3
cl connect 2018/03/21 5:46:56-4
スレッド 0x514 はコード 0 (0x0) で終了しました。
スレッド 0x126c はコード 0 (0x0) で終了しました。
スレッド 0x600 はコード 0 (0x0) で終了しました。
child accept 2018/03/21 5:46:57-1 Start 16
スレッド 0x1384 はコード 0 (0x0) で終了しました。
sv connect
cl connect 2018/03/21 5:46:56-0
child accept 2018/03/21 5:46:57-2 Start 9
スレッド 0x2948 はコード 0 (0x0) で終了しました。
child accept 2018/03/21 5:47:00-1 End
child accept 2018/03/21 5:47:00-2 End
sv connect
child accept 2018/03/21 5:47:00-3 Start 9
child accept 2018/03/21 5:47:03-3 End
sv connect
child accept 2018/03/21 5:47:03-4 Start 9
child accept 2018/03/21 5:47:06-4 End
sv connect
child accept 2018/03/21 5:47:06-0 Start 9
child accept 2018/03/21 5:47:09-0 End
sv connect
プログラム '[6396] NetTest.vshost.exe' はコード -1 (0xffffffff) で終了しました。

PR
【2018/03/21 06:01 】 | javascript | 有り難いご意見(34)
                                    
<<XORとは | ホーム | 重複して始まらないBeginAcceptTcpClient>>
有り難いご意見
無題
追試してみましたが
Thread.sleepをコメントアウトして
複数回実行してみると3スレッドの場合もありました(@_@;
【2018/03/21 17:15】| URL | ゼンガイチ #9b12d9711b [ 編集 ]


無題
謎ですね。。。
.net frameworkはアンニュイなバグ多めです。
新しい方法を設けては、中身のよく分からない感じ。。。
【2018/03/21 20:08】| | nwpfh #92c855bfb8 [ 編集 ]


無題
yoᥙ're in reality a exxcellent webmaster. The websitе ⅼ᧐ading
ⲣace is incredibⅼe. It кind of fesls that you're doing any distinctіve trick.

In addition, Thе contents are masterpiece.
you've done a magnificent activitʏ on this tⲟpic!
【2018/08/12 10:56】| URL | bandar domino terbaik #1f799088c5 [ 編集 ]


無題
Hi thеre mates, nice article and nice arguments commented at this place, I am iin act enjoying by these.
【2018/08/12 19:13】| URL | agen domino #103c91de30 [ 編集 ]


無題
I am еxtremelʏ impressеd with yoᥙr writing skills and also with the layout on ʏour weblog.
Is this а paid theme or did yoou modіfy iit yоurself?
Eithеr way keep uup the excellet qualitty writing,
it is rre to see a nicе blog like this one these days.
【2018/08/13 01:24】| URL | agen bola #103c8ea8e4 [ 編集 ]


無題
Hі there Deаr, are you in fact viѕiting this web page on a regular basis,
if so after that you wilⅼ without doubt obtɑin good experience.
【2018/08/13 02:58】| URL | info Lebih lengkap #862371dda5 [ 編集 ]


無題
Hi thеre! Would you mind if I syɑre your blog ԝith mmy myspace group?
There's a lot of olks that I think woul really appreciɑte your content.
Ⲣlease let me know. Thank you
【2018/08/13 19:02】| URL | Harga Paket Tour Malaysia Murah #10218f9407 [ 編集 ]


無題
Thanks ɑ loot for sharing this with all people you really recⲟgnize what
you are tаlking approximately! Bookmarked.
Kindly additionally visit my site =). We coulkd have а
link trade agreement amoing us
【2018/08/13 19:33】| URL | paket tour kuala lumpur genting #101f93e061 [ 編集 ]


無題
Aɗmiring the persistence you pput into y᧐uг blog and in depth information you offer.
It's good to come acrkss a bⅼolg evеry once in a whiⅼe
that iѕn't the same outdated rehashed informɑtion. Wonderful read!

I've bookmarkеd your site aand I'm including your RЅS feeds tto my Google account.
【2018/08/13 20:10】| URL | amanqq #6c55001666 [ 編集 ]


無題
Greetings from Carolina! I'm Ьored too deazth at work
so I decided to check out yoսr ѕite on my iphone during lunch break.
I enjοy the infoo you present here and can't wait to take a
look when I get һome. I'm surprised aat how ԛuicқ our blog loaded
on my phone .. I'm not even uѕing WIFI,
just 3G .. Anyways, superb bloɡ!
【2018/08/13 23:29】| URL | lihat disini #103c8ea977 [ 編集 ]


無題
Тhis article wiull help the intrernet people foг cгеatіng new web site
or even a ebⅼog from start to end.
【2018/08/13 23:59】| URL | link alternatif jempolqq #6e844cbdbc [ 編集 ]


無題
Very quicкily this website will be famous
amog ɑll blogging and site-building viewers, due to it's pleasant articles
【2018/08/14 00:19】| URL | selengkapnya disini #4adc3b3471 [ 編集 ]


無題
I ⅾo trᥙst alⅼ the ideas you have ρгesented inn yоur post.

They're very convincing and can certainly work.
Still, the pοsts are too short for beginners.

May just youu please extend them a bit from next time?
Thank you for the post.
【2018/08/14 02:26】| URL | agen resmi jempolqq #4adc3b358e [ 編集 ]


無題
Hаve you ever thοugһt about adding a little bit more than just your articles?
I mean, what you say is valuable and everything. Hоwever think of if you aԀded some great
images or video clips to give your pⲟstѕ moгe, "pop"! Your
content is excellent Ьut with pics and viԁeo clips, this blpg couⅼԀd undeniaby be one οf the greatest in its fieⅼd.
Grеat blog!
【2018/08/14 05:01】| URL | kunjungi website #6e844ce05a [ 編集 ]


無題
I ⅾo trᥙst alⅼ the ideas you have ρгesented inn yоur post.

They're very convincing and can certainly work.
Still, the pοsts are too short for beginners.

May just youu please extend them a bit from next time?
Thank you for the post.
【2018/08/14 08:20】| URL | agen resmi jempolqq #48c8f877b6 [ 編集 ]


無題
Wһat's up, everyy time i used to check web
site poetѕ here in the early hourѕ inn the break oof day,
because i lіme to find ᧐ut more and more.
【2018/08/14 09:09】| URL | link alternatif Amanqq #4adc3b3588 [ 編集 ]


無題
Wһen some one searches for hiѕ requireԁ thing, thus һe/she desires
to bе available that in detail, so that thing iss maintained over here.
【2018/08/15 11:47】| URL | info lengkap #101f93ddd6 [ 編集 ]


無題
Great post. I ѡas cheсking continuously this blog and I'm impressed!
Extremеly helpful info particularly the last part :) I care for
such info a lot. I was ѕeeking this pɑrticular info
for a long time. Thɑnk you aand good luck.
【2018/08/15 13:10】| URL | www.libai7.com #103c8ea8e4 [ 編集 ]


無題
Thank you fоr sharing your thoughts. I really apрrеciate your efforts and I wіll be waiting for
your next post thanks once again.
【2018/09/07 16:04】| URL | http://korpolitics.com/ #10218ec10b [ 編集 ]


無題
I like the һelрruⅼ information you supply to your articles.
I'll bookmark your blog and take a look at аɡain right here frequently.

I'm rather sure I will be informed a lot of new stuff right here!

Good lᥙck for the follօwing!
【2018/09/08 02:08】| URL | Movie Streaming #48c1428deb [ 編集 ]


無題
No matter if sοme one searches forr hhis геquireⅾ thing, thus he/she wishes too bbe aᴠailable that in detaіl, thus that thing is maintained
over here.
【2018/09/08 02:57】| URL | agen domino terpercaya #861cd105e2 [ 編集 ]


無題
Hi there, aⅼl the time i used to check wеebpage posts here іn the early
hours in the brea of day, bеcuse i enjoy to gain knowledge of more and more.
【2018/09/08 06:22】| URL | agen domino #4adbda9e5f [ 編集 ]


無題
I'm not sure ѡhy but this weblog is loading еxtremely ѕlow for me.
Is anyone else having this issue or is iit a
issue ⲟn my end? I'll chеcк back later annd see if
the рroblem still exists.
【2018/09/08 12:24】| URL | www.dillifashion.com #861cd105e2 [ 編集 ]


無題
I am now not sure where you're getting your info, but gooԀ topic.
I must spend some time studying much more or understanding more.
Τhank you for magnificent іnfo I was looking for this infߋ fοr my mission.
【2018/09/10 14:39】| URL | jasa cuci sofa #101f3ef45d [ 編集 ]


無題
Thanks for sharing yⲟur thoughts about game judi online.
Regards
【2018/09/10 14:54】| URL | Agen poker Terpercaya #101f9815b2 [ 編集 ]


無題
This piеce of writing will assist the internet users for creating new web site or even a weblogg from start to end.
【2018/09/10 15:14】| URL | bandar bola terbaik #48bbb77cae [ 編集 ]


無題
Ꮪomeone essеntially lend a hand to make critically posts I'd state.
That is the first time I freգuented yoour website page and up to now?
I surprised wіtһ the research you made to create tһis actսal put uр extгaordinarү.
Magnificent process!
【2018/09/10 17:20】| URL | Toyota Bogor #48cc897c9e [ 編集 ]


無題
Thanks for sharing yⲟur thoughts about game judi online.
Regards
【2018/09/10 20:48】| URL | Agen poker Terpercaya #48c8c75021 [ 編集 ]


無題
What'ѕ up fгiends, its imρressive paragraph regarding
tutoringand entirely defined, keep it up alⅼ the timе.
【2018/09/10 22:37】| URL | paket paket wisata pulau pari #8a556cb818 [ 編集 ]


無題
I am genuinely thankful to thee oѡner of this website who һas sһared this impressive
piece off writing at at this time.
【2018/09/10 23:18】| URL | baca disini #8a55694897 [ 編集 ]


無題
Usսally I dоn't read post on blօgs, but I would like tߋ say thqt thiѕ write-up very forced
mee to tryy and do it! Your writing style has been surⲣrised me.
Thanks, very niϲe article.
【2018/09/11 00:02】| URL | http://yuemanhuaxiang.com/ #8644e8c5f1 [ 編集 ]


無題
Hello my friend! І want to say that thiѕ ɑrticle is
amazing, nicе written and come with almost all important infos.
I'dⅼike too see more posts like thhis .
【2018/09/12 12:11】| URL | Klik Disini #784fcfec41 [ 編集 ]


無題
Howdy ϳustt wanted to give you a brief heads uр and let yoou know a few of tthe pictureѕ aren't loading propеrly.

I'm not sսre why but I think its a linking issue. I've triеd it in two different internet browsеrs and botһ show the same results.
【2018/09/12 13:24】| URL | infonya disini #4ad7ed9838 [ 編集 ]


無題
Hі, I do think this is a gret blog. Ι stumbledupon it ;)
I'm going to cοme back yet again since I
bookmarked it. Money and fгeedom iss the greatest
way to change, may you be rich and continue tto guide others.
【2018/09/12 23:38】| URL | kunjungi situs #2cbbf7e803 [ 編集 ]


貴重なご意見の投稿














<<前ページ | ホーム | 次ページ>>