Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ソケットについて
Search
jambo-develop-team
March 11, 2024
0
28
ソケットについて
TCP/IP等ネットワークプロトコルを使って データを双方向で送受信するための手段
TCP/IPという技術を使いやすくした API、ライブラリのようなもの
jambo-develop-team
March 11, 2024
Tweet
Share
More Decks by jambo-develop-team
See All by jambo-develop-team
会社紹介資料_株式会社ジャンボ
jambo_develop_team
0
1k
株式会社Jambo紹介資料
jambo_develop_team
0
630
StoreKit2を使用した課金実装
jambo_develop_team
0
210
AppDelegateで何をすべきか
jambo_develop_team
0
280
SwiftUIのpropertyWrapperをふんわり理解する
jambo_develop_team
0
300
JetpackCompose触ってみた
jambo_develop_team
0
7
KMPを触ってみた
jambo_develop_team
0
17
モバイルアプリの通知機能を AmazonSNSで実装する
jambo_develop_team
0
22
アジャイル入門
jambo_develop_team
0
8
Featured
See All Featured
Done Done
chrislema
181
16k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Gamification - CAS2011
davidbonilla
80
5k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
A Philosophy of Restraint
colly
203
16k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Documentation Writing (for coders)
carmenintech
65
4.4k
Happy Clients
brianwarren
98
6.7k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Site-Speed That Sticks
csswizardry
0
24
Navigating Team Friction
lara
183
14k
It's Worth the Effort
3n
183
27k
Transcript
ીࠜݪޫҰ ιέοτʹ͍ͭͯ
None
ൃදͷత ιέοτ͕Կऀͳͷ͔ Կͱͳ͘ͰΠϝʔδͰ͖ΔΑ͏ʹ͢Δ
݁ہιέοτͬͯԿʁ
5$1*1 ʢݸਓతͳݟղʣ
5$1*1ωοτϫʔΫϓϩτίϧΛͬͯ σʔλΛํͰૹड৴͢ΔͨΊͷखஈ 5$1*1ͱ͍͏ٕज़Λ͍ͨ͘͢͠ "1*ɺϥΠϒϥϦͷΑ͏ͳͷ ͏গ͠۩ମతʹ
ͦͦ5$1*1ͬͯʁ
5$1*1ͱ ௨৴نɾ௨৴ʹ͓͚Δଋࣄ ΞϓϦέʔγϣϯ )551ɺ4.51ɺ%/4 τϥϯεϙʔτ 5$1ɺ6%1 Πϯλʔωοτ
*1ɺ"31ɺ3"31 ωοτϫʔΫΠϯλʔϑΣʔε &UIFSOFUɺ111
Πϯλʔωοτͷׂɺ*1ΞυϨεΛݩʹσʔλ ͷΓऔΓΛ͢Δ૬खΛࢦఆ͢Δ Πϯλʔωοτ
τϥϯεϙʔτͷׂɺσʔλΛదͳΞϓϦέ ʔγϣϯʹৼΓ͚Δ͜ͱ τϥϯεϙʔτ σʔλ σʔλ σʔλ ΞϓϦ" ΞϓϦ#
τϥϯεϙʔτͷׂɺσʔλΛదͳΞϓϦέ ʔγϣϯʹৼΓ͚Δ͜ͱ τϥϯεϙʔτ σʔλ σʔλ σʔλ ΞϓϦ" ΞϓϦ# ϙʔτ൪߸ΛݩʹৼΓ͚
τϥϯεϙʔτͷ௨৴ϓϩτίϧछྨ 5$1ͱ6%1
5$1 5SBOTNJTTJPO$POUSPM1SPUPDPM ૹ͍͍ͬͯʁ ͍͍Αʂ ૹΔͶʂ ίωΫγϣϯܕɹ৴པੑॏࢹ ϝʔϧϑΝΠϧͳͲ࣭ΛٻΊΔ௨৴ʹ༻͢Δ ͪΐͬͱࠞΈ ߹ͬͯΔ ແࣄड͚औͬͨΑʂ
όΠτૹ ΔͶʂ ࠶ૹ͢ΔͶʂ
5$1 5SBOTNJTTJPO$POUSPM1SPUPDPM ૹ͍͍ͬͯʁ ͍͍Αʂ ૹΔͶʂ ίωΫγϣϯܕɹ৴པੑॏࢹ ϝʔϧϑΝΠϧͳͲ࣭ΛٻΊΔ௨৴ʹ༻͢Δ ͪΐͬͱࠞΈ ߹ͬͯΔ ແࣄड͚औͬͨΑʂ
όΠτૹ ΔͶʂ ࠶ૹ͢ΔͶʂ ΣΠϋϯυγΣΠΫ
6%1 6TFS%BUBHSBN1SPUPDPM ͲΜͲΜૹΔΑʂ ίωΫγϣϯϨεܕɹεϐʔυॏࢹ *1ిετϦʔϛϯάαʔϏεͳͲରଟϦΞϧλΠϜੑΛٻΊΔ௨৴ ड͚औΓʹࣦഊ͠ ͓ͯߏ͍ͳ͠ ؾʹͤͣૹΔΑʂ
ৄͪ͘͜͠Β εϥεϥΘ͔ΔωοτϫʔΫ 5$1*1ͷ͖΄Μ
5$1*1͔͚ͬͨͲιέοτʁ
5$1ʹ͓͚Διέοτ௨৴ͷྲྀΕʹ͍ͭͯ ιέοτ௨৴͢ΔػثɺͦΕͧΕͰιέοτͷ࣮͕ඞཁ ίωΫγϣϯͷ४උ ίωΫγϣϯͷཱ֬ σʔλަ ίωΫγϣϯͷղ์
αʔόʔ ΫϥΠΞϯτ 4PDLFU 4PDLFU MJTUFO DPOOFDU SFDFJWF TFOE SFDFJWF TFOE
DMPTF DMPTF ίωΫγϣϯ४උ ίωΫγϣϯཱ֬ σʔλަ ίωΫγϣϯղ๏
ιέοτΫϥΠΞϯτଆ final class SocketClient { init(_ loginUser: LoginUserEntity) { self.loginUser
= loginUser let host = NWEndpoint.Host(CustomUrl.targetIp) let port = NWEndpoint.Port(integerLiteral: CustomUrl.Port) let using: NWParameters = .tcp connection = NWConnection(host: host, port: port, using: using) connection.stateUpdateHandler = {[weak self] newState in guard let strongSelf = self else { return } strongSelf.connectionState = newState switch newState { case .setup: print("HOGE: ηοτΞοϓ”) case .waiting: print("HOGE: ػ") case .preparing: print("HOGE: ४උ") case .ready: print("HOGE: ४උྃ”) private static let productionIp = “xxx.com” static let port: UInt16 = 8_888 J04ΞϓϦ ιέοτॳظԽॲཧ ίωΫγϣϯͷ४උ ίωΫγϣϯཱ֬
ιέοτΫϥΠΞϯτଆ final class SocketClient { init(_ loginUser: LoginUserEntity) { self.loginUser
= loginUser let host = NWEndpoint.Host(CustomUrl.targetIp) let port = NWEndpoint.Port(integerLiteral: ɹɹɹɹɹɹɹɹɹɹɹCustomUrl.port) let using: NWParameters = .tcp connection = NWConnection(host: host, port: port, using: using) connection.stateUpdateHandler = {[weak self] newState in guard let strongSelf = self else { return } strongSelf.connectionState = newState switch newState { case .setup: print("HOGE: ηοτΞοϓ”) case .waiting: print("HOGE: ػ") case .preparing: print("HOGE: ४උ") case .ready: print("HOGE: ४උྃ”) private static let productionIp = “xxx.com” static let port: UInt16 = 8_888 Πϯλʔωοτ τϥϯεϙʔτ τϥϯεϙʔτ ʁʁʁ
ιέοτΫϥΠΞϯτଆ final class SocketClient { init(_ loginUser: LoginUserEntity) { self.loginUser
= loginUser let host = NWEndpoint.Host(CustomUrl.targetIp) let port = NWEndpoint.Port(integerLiteral: ɹɹɹɹɹɹɹɹɹɹɹCustomUrl.port) let using: NWParameters = .tcp connection = NWConnection(host: host, port: port, using: using) connection.stateUpdateHandler = {[weak self] newState in guard let strongSelf = self else { return } strongSelf.connectionState = newState switch newState { case .setup: print("HOGE: ηοτΞοϓ”) case .waiting: print("HOGE: ػ") case .preparing: print("HOGE: ४උ") case .ready: print("HOGE: ४උྃ”) private static let productionIp = “xxx.com” static let port: UInt16 = 8_888 Πϯλʔωοτ τϥϯεϙʔτ τϥϯεϙʔτ ΣΠϋϯυγΣΠΫ
ιέοτΫϥΠΞϯτଆ func send(to receiver: SocketMsgProtocol, text: String, messageType: ChatMessageType, handler:
@escaping (SocketMessage?) -> Void) { ~~~~ } func receive(on connection: NWConnection) { connection.receive(minimumIncompleteLength: 0, maximumLength: Int(UInt32.max)) {[weak self] (data, _, _, error) in guard let text = data?.toStringWithEncodeByUTF8() ~~~ } σʔλަ
ιέοτΫϥΠΞϯτଆ func releaseSocketClient() { socketClient = nil } ɹɹdeinit {
connection.cancel() } ίωΫγϣϯͷղ์
·ͱΊ w 5$1*1ͷٕज़Λͬͯ؆୯ʹσʔλͷΓऔΓΛߦ͑ΔΑ͏ ʹͨ͠ͷ͕ιέοτ w 5$1ͱ6%1ͱ͍͏̎ͭͷ௨৴ϓϩτίϧ͕͋Δ w ࣄͷຊ࣭Λָ͍ͬͯ͘͠͞
͓ΘΓ